kvnirvana Posted September 30, 2011 Share Posted September 30, 2011 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 More sharing options...
Buddski Posted September 30, 2011 Share Posted September 30, 2011 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);} Link to comment https://forums.phpfreaks.com/topic/248178-order-by-name-asc-problem/#findComment-1274388 Share on other sites More sharing options...
kvnirvana Posted September 30, 2011 Author Share Posted September 30, 2011 Thank you so much Link to comment https://forums.phpfreaks.com/topic/248178-order-by-name-asc-problem/#findComment-1274389 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.