Jump to content

Random numbers to DB


magnetica

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.