DamienRoche Posted January 3, 2009 Share Posted January 3, 2009 I have a very simple mysql query which fetches some results using a while loop: <?php $data=mysql_query("SELECT * from cats ORDER BY 'ord' ASC"); while($fetch=mysql_fetch_array($data)){ $maincat = $fetch['maincat']; $mainkey = $fetch['mainkey']; $order = $fetch['ord']; echo "$maincat, $mainkey, $order<br>"; } ?> ...thing is, I just can't seem to order this ouput by anything. Is it the while statement? Thanks. Link to comment https://forums.phpfreaks.com/topic/139379-solved-phpmysql-order-by-with-while-loopi-must-be-missing-something/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 3, 2009 Share Posted January 3, 2009 Why are there single-quotes around ord in the query? That makes it into a string and not your column name. Link to comment https://forums.phpfreaks.com/topic/139379-solved-phpmysql-order-by-with-while-loopi-must-be-missing-something/#findComment-728993 Share on other sites More sharing options...
DamienRoche Posted January 3, 2009 Author Share Posted January 3, 2009 lmao...seriously, I should give this up. Damn syntax error. I jsut figured that's how it had to be, since when I refer to the cols, I use '' in the fetch. Never mind, thanks! Link to comment https://forums.phpfreaks.com/topic/139379-solved-phpmysql-order-by-with-while-loopi-must-be-missing-something/#findComment-728999 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.