I am trying to run this php script.... Right now the array has 3 rows, 3 different schools same person/number. When I post/submit the updated information, it only post row 1 and row 3 with row 1 posted value. It doesn't not change the row 2 values. My question.. Are there any red flags that stick out? If this is the script why are only certain rows being updated and not all rows? Do I need a that will execute it time through the loop?
<?php
for ($i=0; $i<count($_POST['row']); $i++){
$number = 223;
$row = $i+1;
$school = mysqli_real_escape_string($con, $_POST['school'][$i]);
$query = " set @type = '';";
$query .= " set @num = 1;";
$query .= " update person set person.school = '$school' where person.id in (";
$query .= "select t.id from (";
$query .= "select *, @num:= if(@type = number, @num + 1, 1) as num, @type := number as Dummy from person order by it desc) as t where t.number = '$id' and num = '$row');";
mysqli_multi_query($con, $sql);
?>
This is what I get when the php is ran. I broke it up so you can see.
set @type = '';
set @num = 1;
update person set person.school = 'Harvard1' where person.id in (select t.id from (select *, @num:= if(@type = number, @num + 1, 1) as num, @type := number as Dummy from person order by it desc) as t where t.number = '223' and num = '1');
set @type = '';
set @num = 1;
update person set person.school = 'Harvard2' where person.id in (select t.id from (select *, @num:= if(@type = number, @num + 1, 1) as num, @type := number as Dummy from person order by it desc) as t where t.number = '223' and num = '2');
set @type = '';
set @num = 1;
update person set person.school = 'Harvard3' where person.id in (select t.id from (select *, @num:= if(@type = number, @num + 1, 1) as num, @type := number as Dummy from person order by it desc) as t where t.number = '223' and num = '3');