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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.