Hi
Semi - know enough to be dangerous- newby here 😃
I want to display a random field from a database.
I have this (names changed to protect the innocent
$categ = mysql_query("SELECT * FROM table WHERE field= 1")
or die("SELECT Error: ".mysql_error());
$num_rows = mysql_num_rows($categ);
srand ((double)microtime()*1000000);
$randomnum = rand(1, $num_rows);
this works well I get the number of rows, and then a random number from 1 to the # of rows.
Now: how do I select that index from the array??
(and also, should my random number be from 1 to $num_rows or from 0 to ($num_rows - 1) ???)
I can display ALL of the rows by using
While ($categs = mysql_fetch_array($categ)):
echo $categs['message']."<BR>";
endwhile;
I had tried using and index, and it worked great... until someone deleted a row.
I know this should be easy . . . . . .