Here is the Drupal 8 Query to get category info
here category name “color_cat”
$vid = ‘color_cat’;
$parent_tid = 0;//parent id
$depth = 2; //depth upto which level you want
$load_entities = FALSE;
$cat_data= \Drupal::entityTypeManager()->getStorage(‘taxonomy_term’)->loadTree($vid,
$parent_tid, $depth, $load_entities);
$variables[‘color_cat’] = $cat_data;
add below code inside your .theme file
in .twig file you have use below twig code to display category name
{% for key1, value in color_cat %}
{{ color_cat[key1]['name'] }}
{% endfor %}
one of the most conman error when connecting to MySQL server is “host is not allowed to connect to this MySQL server” this because of the user don’t have right privileges to connect to this MySQL server follow below steps to connection issue in MySQL
if you have full permission in MySQL
Open Mysq-> phpmyadmin
Go to User accounts section
Create a new user and give all the privilege as shown in the below image
if you have cpanel info
Go to MySQL® Databases section
Scroll down to Add New User section
After Scroll down to Add User To Database section
Select table and user and Add User To Database
Click all ALL PRIVILEGES and Make Changes
Here is the simple MySQL query to fetch data between given date range
See MySQL query
$f_date=$_REQUEST['f_date'];
$t_date=$_REQUEST['t_date'];
"SELECT * FROM sales WHERE sales_invoice_date between '".date('Y-m-d',strtotime($f_date))."' and '".date('Y-m-d',strtotime($t_date))."' "
To Fetch all the sales data in the given date
"SELECT * FROM sales WHERE sales_invoice_date='".date('Y-m-d',strtotime($f_date))."'"
To fetch Today’s Sales
SELECT * FROM sales WHERE STR_TO_DATE(sales_invoice_date , '%d-%m-%Y') = CURDATE()