Random results without Repeat on Pagination

Hi I have a section of my site that the clients wants to be random instead of displayed in a logical order located here.

http://www.altoonastudenthousing.com/search.php?&page=0

It has pagination for all of the listings … Is there a way list them randomly but not repeating the results pages forward so everyone gets a fair listing?

this is the code currently
[php]else
$sql2.= ’ featured, RAND() ';

if (isset($search[‘order_by’]) && $search[‘order_by’] != ‘ANY’
&& isset($search[‘order_by_type’]) && $search[‘order_by_type’] != ‘ANY’ &&
($search[‘order_by_type’] == ‘DESC’ || $search[‘order_by_type’] == ‘ASC’ ))
$sql2.= $search[‘order_by_type’];

$sql2.= ’ LIMIT ’ . $results_page . ', ’ . $conf[‘search_results’];

// End creating sql query

// If property type specified we add it into the table
// header

if (isset($search[‘type’]) && $search[‘type’] != ‘ANY’) {
// Select all property types from the database
$sql5 = 'SELECT id, ’ . $language_in . ', counter FROM ’ . TYPES_TABLE . ’ WHERE id = ’ . $search[‘type’];
$r5 = $db->query ( $sql5 ) or error (‘Critical Error’, mysql_error () );
$f5 = $db->fetcharray( $r5 );
$table_category = ’ / ’ . $f5[1];
}
else
$table_category = ‘’;[/php]

Just shuffle the array after fetching records from the DB

Still a serious noob as far coding…

I have looked at the shuffle function… What would I replace in the code?

It’s kinda hard to say as your code is incomplete and have terrible variable names

I think this should do it

[php] $sql5 = 'SELECT id, ’ . $language_in . ', counter FROM ’ . TYPES_TABLE . ’ WHERE id = ’ . $search[‘type’];
$r5 = $db->query ( $sql5 ) or error (‘Critical Error’, mysql_error () );
$f5 = $db->fetcharray( $r5 );
$table_category = ’ / ’ . $f5[1];[/php]–>[php] $sql5 = 'SELECT id, ’ . $language_in . ', counter FROM ’ . TYPES_TABLE . ’ WHERE id = ’ . $search[‘type’];
$r5 = $db->query ( $sql5 ) or error (‘Critical Error’, mysql_error () );
$f5 = $db->fetcharray( $r5 );
shuffle($f5);
$table_category = ’ / ’ . $f5[1];[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service