Code
<? PHP
Header ("Content-Type: text/html; charset = UTF-8 ");
$ Mysql_host = 'localhost ';
$ Mysql_un = 'root ';
$ Mysql_pwd = '000000 ';
$ My_db_name = 'mytestdb ';
$ My_table_name = 'mytesttable ';
$ Output_str = '';
$ Resource = mysql_connect ($ mysql_host, $ mysql_un, $ mysql_pwd) or die ('mysql connect error! ');
Mysql_select_db ($ my_db_name, $ Resource );
$ Result = mysql_query ("select ID from $ my_table_name", $ Resource) or die ('select data error ');
$ My_id_array = array ();
While ($ ROW = mysql_fetch_assoc ($ result )){
If (is_numeric ($ row ['id']) {
$ My_id_array [] = $ row ['id'];
}
}
Mysql_free_result ($ result );
If (count ($ my_id_array)> 0 ){
$ Rand_query_id = array_rand ($ my_id_array, 1 );
$ Result = mysql_query ("select * from $ my_table_name where id = $ rand_query_id", $ Resource) or die ('select data error2 ');
$ ROW = mysql_fetch_assoc ($ result );
$ Output_str = "<Table> <tr> <TD >{$ row ['foodname'] }</TD> <TD >{$ row ['price']} </ TD> <TD >{$ row ['tele'] }</TD> </tr> </table> ";
Mysql_free_result ($ result );
} Else {
$ Output_str = 'withoutany data ';
}
Mysql_close ($ Resource );
Echo $ output_str;
?>
Select * From tablename order by rand () limit 1 MySQL can actually implement this function