Current course:

MySQL Random


The code

$query = mysql_query("SELECT first, last FROM students ORDER BY RAND() LIMIT 1");
while($row = mysql_fetch_object($query)) {
      echo $row->first . "<br />";
}

This will pull one student from the students table. It only pulls one because of the "LIMIT 1" at the end. And it uses "RAND()" to pull them in a random order.