I want to randomly update a field in the database. I am using this, but it overwrites the first ones.
$dealer_SALESPERSON = "5,6,7,8";
for($i = 0; $i < count($dealer_SALESPERSON); $i++){
$query = "UPDATE $catagory SET user_ownership='$dealer_SALESPERSON[$i]' WHERE SALESPERSON='$SALESPERSON'";
print "$query <br>";
$result = mysql_query($query) or die(mysql_error());
print "Thank you information updated!\n";
}
It's spiting out the correct queries, but the last is overwriting the first ones,
UPDATE DEMO SET user_ownership='5' WHERE SALESPERSON='TOP SALESPERSON 1'
UPDATE DEMO SET user_ownership='6' WHERE SALESPERSON='TOP SALESPERSON 1'
UPDATE DEMO SET user_ownership='7' WHERE SALESPERSON='TOP SALESPERSON 1'
UPDATE DEMO SET user_ownership='8' WHERE SALESPERSON='TOP SALESPERSON 1'
I want it to evenly divide the 5,6,7,8 WHERE SALESPERSON='TOP SALESPERSON 1', or randomly do it.