magnetica Posted August 15, 2009 Share Posted August 15, 2009 Whats wrong here because this works but edits all the rows and not specific and if i put a where clause in then it doesnt work at all. $result = mysql_query("SELECT * FROM videos"); while($row = mysql_fetch_array($result)){ $rand1 = rand(60,125); mysql_query("UPDATE `a8129045_central`.`videos` SET thumbs_up = '$rand1'"); } Link to comment https://forums.phpfreaks.com/topic/170417-random-numbers-to-db/ Share on other sites More sharing options...
ignace Posted August 15, 2009 Share Posted August 15, 2009 mysql_query("UPDATE `a8129045_central`.`videos` SET thumbs_up = '$rand1'"); Updates each and every row meaning all rows will get the last random number given. Use: $id = $row['id']; mysql_query("UPDATE `a8129045_central`.`videos` SET thumbs_up = '$rand1' WHERE id = '$id'"); Link to comment https://forums.phpfreaks.com/topic/170417-random-numbers-to-db/#findComment-898978 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.