A
Anonymous
Guest
Try this code:
Code:
$temphandle=explode(",",$_POST["oldname"]);
$tempcount=count($temphandle);
$link=mysql_connect("$host","$user","$password");
mysql_select_db($dbname,$link);
for($a=0; $a < $tempcount; $a++)
{
$test="select * from employlist where employlist.fname='".$temphandle[$a]."'";
$display=mysql_query($test,$link);
$row=mysql_num_rows($display);
if($row<>0){
$row=mysql_fetch_array($display);
$htemp=explode(",",$row["projects"]);
$hcnttemp=count($htemp);
$tempvalue="";
$del=0;
for($cnt=0;$cnt < $hcnttemp; $cnt++){
if($htemp[$cnt]!=$projname){
if((abs($hcnttemp-$cnt-$del))<=2){
$tempvalue.=$htemp[$cnt];
}else{
$tempvalue.=$htemp[$cnt].",";
}
}else{
$del++;
}
}
$Query = "Update employlist set employlist.projects='". $tempvalue."' where (employlist.fname='".$temphandle[$a]."')";
$save=mysql_query($Query);
if(!$save)
print "did not save";
}
$display = null;
$test=null;
$row=null;
}
}
mysql_close($link);
?>