Page 1 of 1

Ramdom results?

Posted: Tue Dec 23, 2003 6:09 am
by Perfidus
I have a DB in which one table has info about cities, I would like to query the table in order to choose ramdomly one of the cities and show the info.
Any hints?

Merry Christmas to everyone and peace one day!;)

Posted: Tue Dec 23, 2003 7:57 am
by qads
you could use RAND in the query but you need to have..uh..i forgot what version it was implaneted in, try it in ways:

Code: Select all

<?php
$query = query("select city from tablename ORDER BY rand()  LIMIT 5");
?>
if that doest work then get the data into a array and use [php_man]array_rand[/php_man] :) .