Hey,
Im a beginner in PHP. Does anyone know the code for what I want to do?
I would like to select a random row from a table in a database and put each column into a variable.
Thanks everyone!try this
$result = mysql_query("SELECT * FROM mytable ORDER BY RAND()");
$r = mysql_fetch_array($result);
Should Display a single row but you can do a loop and it should display results in random order$result = mysql_query("SELECT * FROM mytable ORDER BY RAND() limit 0,1");
Im a beginner in PHP. Does anyone know the code for what I want to do?
I would like to select a random row from a table in a database and put each column into a variable.
Thanks everyone!try this
$result = mysql_query("SELECT * FROM mytable ORDER BY RAND()");
$r = mysql_fetch_array($result);
Should Display a single row but you can do a loop and it should display results in random order$result = mysql_query("SELECT * FROM mytable ORDER BY RAND() limit 0,1");