Help modify this code:

$result = mysql_query("SELECT * FROM userinfo LIMIT 1") or die('MYSQL ERROR:'.mysql_error()); $myrow = mysql_fetch_array($result); echo $myrow[name]; 

I need to make a mill type, so that he would deduce random from the database, so that the update always changes the record. Who can help?! But I really wanted to through js, and he changed, let's say every 30 seconds

  • ORDER BY RAND (), but that's bad. - ModaL
  • but how can you do what would be good, and let's say it changed every 30 seconds - svoloch196
  • Ajax to help you, but this is quite a complicated technology for beginners - MDJHD

1 answer 1

 $query = "SELECT * FROM userinfo LIMIT 1"; $result = mysqli_query($link, $query) or trigger_error('MYSQL ERROR:'.mysqli_error($link)." ".$query); if($result){ $myrow = mysqli_fetch_array($result); } echo $myrow[name]; 

I advise you to replace your code with this one!

$ link - connect to the database via mysqli_connect

  • In humans, the mysql module is used, but the point I think is this: do not use the mysql module) I've probably been sitting on PDO_MySQL for a year and a half. - Andrey Arshinov
  • I myself do not know how to replace approximately everything, if it is not difficult for you to give the code already with connection to the database, it is desirable for me through a timer that changes every 30 svoloch196