Döngü için iyi dizi yapısına uygun bir yolu var mı

0 Cevap php

OK so I have this page and as you can see I am loggering the array of 12 products. If you scroll down you can see the requirements are that i need to group them by category name but i am not sure the best way to structure the loops.

my query

$query = "SELECT p.name, p.price, pc.quantity, p.image, p.descr, t.name as Category_name
          FROM products as p
          join categorizations as pc on p.id = pc.product_id
          join categories as c on c.id = pc.category_id
          JOIN types AS t on t.id = p.type_id
          WHERE  c.code      = '{$type}_{$count}'
          order by p.order desc";

$allproducts = array();
while($row_r = mysql_fetch_assoc($result)){
  $allproducts[] = $row_r;
}

belki ben kategori adına göre gruplandırmak benim sorgu veya bir şey değiştirmek gerekir ama bu bazı ürünler düşebilir. belki ben bir multidemensional dizi ve döngü her kategori ismini oluşturabilirsiniz

herhangi bir öneri

0 Cevap