View Single Post
Old 10-30-2011, 11:19 AM  
eMonk
Confirmed User
 
Industry Role:
Join Date: Aug 2003
Location: Canada
Posts: 2,310
Sorry one more question about this....

I'm trying to display to results by RAND() and have added the following to the top of the code:

Code:
session_start();

$rand = $_SESSION['rand'];
if (empty($rand)) {
  srand((float)microtime()*1000000);
  $rand = "0.".rand();
  $_SESSION['rand'] = $rand;
}
Which works but when you click on page 2, etc it gets randomized again.

How can I have it so when you refresh the page or revisit it randomizes the results but doesn't again when you click on page 2, page 3, etc?

I tried adding in the following in a few places but doesn't seem to do anything:

Code:
if(isset($_SESSION['rand']))
    unset($_SESSION['rand']);
Also updated the $data_p query and now it looks like this:

Code:
$data_p = "SELECT * FROM model WHERE status = 'Active' ORDER BY RAND($rand) $max";
eMonk is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote