I am developing an application that updates data in a table based on values selected from another table. I had searched the net,a nd tried to modify some samples to fit my needs, but still not working.
Below is some of my code:
$sync_2 = "
select pin,ddt_1
from purchases
where (amount_to_repay-amount_repaid)>0
and status like 'U%'
and counter=1
";
$sync_2_res = mysqli_query($link, $sync_2);
$row = mysqli_fetch_assoc($sync_2_res);
$data = mysqli_num_rows($sync_2_res);
$i;
for ($i = 0; $i <= $data; $i++) {
$pin = $row['pin'];
$ddt = $row['ddt_1'];
$sql = "
update deductions
set amount = '$ddt_1'
where pin = '$pin';
$result = mysqli_query($link,$sql);
}
Nothing is getting populated. Do I have to change the type of loop?.
'on$row['ddt']this would cause the script to give an error.