Jump to content

[SOLVED] while loop random order


almightyegg

Recommended Posts

It will eventually have 100+ rows BUT I've just realised, using rand() would mean pagination wouldn't work because it randomise every page so chances are some will be listed twice and some won't be listed at all on the pages....is there a way around that??

oow not a 'nice way' that i can think of,

 

unless you return only the ID's and store them in array and then use something like 'where  ID in ('.explode($storedID's, ",").') ' but thats tacky

 

would have to be a session,

 

 

 

storing a 100+ records in a array to be passed page to page is more tacky

u can still use pagination simply do it like this

$query  = mysql_query('SELECT ....... LIMIT 5,20');
while(.........)
{
$array[$id] = $idortext;
}
shuffle($array);
foreach($array ...... )
{
echo ......;
}

the only thing about using shuffle is if you need to keep the array keys they will be changed

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.