<?php

include 'connect.php';

ini_set('max_execution_time', 50000);

$sel=mysql_query("select * from followup where ID='1' order by ID asc");
while($sel1=mysql_fetch_array($sel))
{

$rr=mysql_query("select * from followup where customer='$sel1[customer]' and ID<'$sel1[ID]' order by ID desc limit 1");
$rnm=mysql_num_rows($rr);
$rr1=mysql_fetch_array($rr);

if($rnm>0)
{

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

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

}

}


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



?>