Jump to content

ORDER BY functions


czukoman20

Recommended Posts

you could do

 

$random = rand(1,2);
switch ($random) {
   case 1:
      $random = "DESC";
      break;
   case 2:
      $random = "ASC";
      break;
}

 

And then the query would be "SELECT * FROM table ORDER BY `id` ".$random."" (assuming there is an id column)

You could of course expand the random range and add more options

 

or actually

 

$random = rand(0,1);
$options = array("DESC","ASC");

 

"SELECT * FROM table ORDER BY `id` ".$options[$random].""

Link to comment
https://forums.phpfreaks.com/topic/81856-order-by-functions/#findComment-415864
Share on other sites

ok well my problem is deeper than this now that i have found out.. and im just lost now.. .. . ...  ugh>!? ! and this has to go with my random pagination. so if you guys are looking at this one.. then can you please read the topic that is random pagination. because that is the base of what this problem is thanks.

Link to comment
https://forums.phpfreaks.com/topic/81856-order-by-functions/#findComment-415971
Share on other sites

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.