This is something i wrote some time ago to do close to the same thing
$sql1 = "select pgid, fname , mname , lname ,gdpi , catcode from $tname7";
$res1 = mysql_query($sql1,$connection) or die (mysql_error());
while ($row1 = mysql_fetch_array($res1))
{
$pgid = $row1["pgid"];
$fname = $row1["fname"];
$mname = $row1["mname"];
$lname = $row1["lname"];
$gdpi = $row1["gdpi"];
$catcode = $row1["catcode"];
$sqlc = "UPDATE $tname17 SET v_fname = '$fname' , v_mname = '$mname' , v_lname = '$lname' , v_catcode = '$catcode' , v_gdpi = '$gdpi' WHERE pgid = '$pgid'";
$resc = mysql_query($sqlc) or die (mysql_error());
Pradeep Dsouza
Aspbyte Creations.com
Naharonline.com