I am trying to update all of the rows in a table in my database with a different value. I am trying to while loop the query to do this. Here's what I have...
<?php
$rand = rand(100,150000);
$start = 1;
$start += $start;
$start2 = $start +1;
echo $start;
while($start =< 686) {
echo "UPDATE table_video SET total_view = $rand WHERE id BETWEEN $start AND $start2;";
};
?>
I am sure most of you should be able to look at my code and understand what I am trying to accomplish. I would like the assistance. Thank You very much!
$randalso will only be generated once. All records will have the same integer on each iteration. You should put the assignment in the loop.$startthing... you initialise it to1. Then you add1($start = 2) and then$start2is$start + 1which is3. (I don't know why you do all of that tbh. Then you make awhile-statementthat never ends because you're never increasing the$start(so it always is$start =< 686).UPDATE table_video SET total_view = 74956 WHERE id = 1;thenUPDATE table_video SET total_view = 54687 WHERE id = 2;... I made a mistake in my question, the BETWEEN was for a different trial and error.