11
It says to use only one list.
Or you make for every category the product list in PHP and output that everytime to the template.
Or you make a combined sorted list with category and product data in it and output that to the template which then checks changes in the category data to insert a category header.
In general, I think the first method is the more efficient.
{
$stat['qty']=$row['total_qty'];
$stat['p_name']=$row['p_name'];
}