RE: [PHP] display query results at random

From: Date: Wed, 26 Sep 2001 03:56:26 +0000
Subject: RE: [PHP] display query results at random
Groups: php.general 
Request: Send a blank email to php-general+get-68812@lists.php.net to get a copy of this message
Return into an array, then loop through the array or shuffle it (easier)?. Note if you have nulls in DB, you will have to do something different. n'est pas? -------- e.g. (untested) mysql_fetch_array <?php mysql_connect ($host, $user, $password); $result = mysql_db_query ("database","select user_id, fullname from table"); $j=0; while ($row[$j] = mysql_fetch_array ($result)) { $j++; } mysql_free_result ($result); srand ((float)microtime()*1000000); shuffle ($row); //do output stuff with array ?> -----Original Message----- From: Matthew Delmarter [mailto:matt@adplusonline.com] Sent: September 26, 2001 12:01 PM To: PHP Mailing List Subject: [PHP] display query results at random How do I return a specific record from a db outside of the query? Let's say I "select * from table" (using mysql_fetch_object) and get 5 results. I want to display the 5 results in different / random places on the page. Place 1 - show details for record 3 Place 2 - show details for record 1 Place 5 - show details for record 5 How do I do this? I know how to loop thru a mysql result - but what if want to display things in a random order around the page? I could have multiple select statements - but this would increase the load on the server and is unnecessary as all the data was returned from the query - it's just a matter of knowing how to get it! Can anyone help? I am sorry if the question is confusing, but I can't think of a better way to explain it at the moment (i'm tired)... Matthew -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#68812) next »