Jump to content

random select from Mysql using PHP


orbitter

Recommended Posts

hmmmm your code will be something lyk...

 

<?
$noobs= mysql_query("SELECT * FROM users ORDER BY RAND()");
$no_of_noobs= mysql_num_rows($noobs);

if ($no_of_noobs == "0"){
echo "No noobs could be selected from the db";
}else{

$the= mysql_fetch_object($noobs);
echo $the->username;

}
?>

you might have to change a few stuff accordingly to your database

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.