Jump to content

ORDER BY name ASC problem


kvnirvana

Recommended Posts

I need to add ORDER BY name ASC to this code

 

foreach($db->query("SELECT * FROM company_subcategory WHERE category_id = ".(int) $category_id) as $row) { $r[] = new CompanySubCategory($row['subcategory_id'], $row);}

 

Tried to do it like this, but it doesn't work

 

foreach($db->query("SELECT * FROM company_subcategory WHERE category_id = ".(int) $category_id ORDER BY name ASC) as $row) { $r[] = new CompanySubCategory($row['subcategory_id'], $row);}

 

Any help much appreciated

 

Thanks in advance

Link to comment
https://forums.phpfreaks.com/topic/248178-order-by-name-asc-problem/
Share on other sites

You will need to close the quote around the $category_id, assuming that the original code worked :)

foreach($db->query("SELECT * FROM company_subcategory WHERE category_id = ".(int)$category_id." ORDER BY name ASC") as $row) { $r[] = new CompanySubCategory($row['subcategory_id'], $row);}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.