<?php

include 'connect.php';

ini_set('max_execution_time', 50000);

$sel=mysqli_query($conn,"select * from followup where ID='1' order by ID asc");
while($sel1=mysqli_fetch_assoc($sel))
{

$rr=mysqli_query($conn,"select * from followup where customer='$sel1[customer]' and ID<'$sel1[ID]' order by ID desc limit 1");
$rnm=mysqli_num_rows($rr);
$rr1=mysqli_fetch_assoc($rr);

if($rnm>0)
{

$ldate=date('d-m-Y',strtotime($rr1['date']));

$up=mysqli_query($conn,"update followup set lastfollowup='$rr1[date]',lastremarks='$rr1[remarks]' where ID='$sel1[ID]'") or die(mysqli_error($conn));

}

}


if($up)
{
echo"success";
}



?>