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'"); } Quote Link to comment 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'"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.