$query = mysql_query("SELECT * FROM words"); $id = rand(1, mysql_num_rows($query)); $sql = "SELECT word FROM words WHERE id=$id";