Hi Experts,I have 2 pages with the name farmmgmt.php and assigndoc.php. In farmmgmt.php I insert certain fields like cowid and then get redirected to assigndoc.php for assigning doctors.
After assigning when I update the table it does not do so..
I want to update the table for the recently inserted cowid only..
Here's the code of farmmgmt.php
$insert = "INSERT INTO `farmlogin` (`uid`, `name`, `imgpath`, `gender`, `date`, `age`, `bb`, `htno`, `htunit`, `lno`, `lunit`, `pric`, `clr`, `insured`, `inscomp`, `polname`, `premiumtype`, `premiumamt`, `insstdate`, `matdate`, `remk`) VALUES ('$d', '$n', '$f', '$gen', '$dt', '$umar', '$bo', '$hgt', '$unitht', '$lgt', '$unitl', '$pr', '$colo', '$check', '$cname', '$poly', '$premtype', '$amt', '$insurancedat', '$mat', '$rk')";
$result = mysql_query($insert);
$latest = mysql_insert_id();//to get the latest inserted aoutoincremented cowid from the table
$i = $_GET['y'];
$sql = "UPDATE `farmlogin` SET `doc` = '$i' WHERE `cowid` = '$latest'";
echo "$sql";
$data = mysql_query($sql);
//$ve = intval($_GET['d']);
//$s = "UPDATE `farmlogin` SET `vend` = '$ve' WHERE `cowid` = '$latest' AND `doc` = '$i'";
//echo "$s";
//$d = mysql_query($s);
if($result)
{
echo "<script>location.href='http://localhost/assigndoc.php'</script>";
}
else
{
echo "hello";
}
Next is of assigndoc.php
if(isset($_REQUEST['submit']))
{
$q = "SELECT `docid`, `doctor`, `hospital` FROM `docinfo` WHERE `city` = '$cc'";
$r = mysql_query($q);
echo "<b>Doctor</td>";
echo "<td><b>Hospital Name</td>";
echo "<td><b>Assign Doctors</b></td>";
echo "<tr>";
while($row = mysql_fetch_array($r))
{
echo "<td>".$row[doctor]."</b></td>";
echo "<td>".$row[hospital]."</td>";
echo "<td><a href=farmmgmt.php?y={$row['docid']}>Assign</a></td>";
echo "</tr>";
}
Please help out