RCB Posted February 19, 2009 Share Posted February 19, 2009 hey guys i was just wondering if i have to make 2 separate queries to get basically the same info just display in a different order... can i do it with 1 query? the first 1 would be ORDER BY added DESC second would be ORDER BY rand() thx Quote Link to comment https://forums.phpfreaks.com/topic/146001-do-i-need-2-queries-just-for-an-order-by-change/ Share on other sites More sharing options...
revraz Posted February 19, 2009 Share Posted February 19, 2009 You can use one if you use a variable as your ORDER BY Quote Link to comment https://forums.phpfreaks.com/topic/146001-do-i-need-2-queries-just-for-an-order-by-change/#findComment-766510 Share on other sites More sharing options...
sasa Posted February 19, 2009 Share Posted February 19, 2009 maybe <?php $result = mysql_query("SELECT ... ORDER BY added DDESC"); $order = range(0, mysql_num_rows($result)); foreach ($order as $i){ echo mysql_result($result, $i, 'field name'); // etc. } shuffle($order); foreach ($order as $i){ echo mysql_result($result, $i, 'field name'); // etc. } ?> Quote Link to comment https://forums.phpfreaks.com/topic/146001-do-i-need-2-queries-just-for-an-order-by-change/#findComment-766514 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.