Loop In Updating Table Data With Php And MySQL
<p>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.</p>

<p>Below is some of my code:</p>

<pre><code>$sync_2 = "
  select pin,ddt_1
  from purchases
  where (amount_to_repay-amount_repaid)&gt;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 &lt;= $data; $i++) {
  $pin = $row['pin'];
  $ddt = $row['ddt_1'];
  $sql = "
    update deductions
    set amount = '$ddt_1'
    where pin = '$pin';
  $result = mysqli_query($link,$sql);
}
</code></pre>

<p>Nothing is getting populated. Do I have to change the type of loop?.</p>
