How to display last data where name is same. I think my $result is wrong. Please help me solve it. Thank you
$SearchQ = "SELECT * FROM tblperson where Id = ".$_GET['Id'];
$SearchResult = mysql_query($SearchQ,$link);
$StaffRec = mysql_fetch_array($SearchResult);
<input type="text" name="txtPastDate" id="txtPastDate" value="<?php
$result = mysql_query("SELECT * from tblvisit order by tblvisit.Id desc limit 1 where tblvisit.PatientName = $StaffRec['Name']");
while($row = mysql_fetch_assoc($result))
{
echo $row['VisitDate'];
}
mysql_free_result($result);
?>"/>
Your query would be
$result = mysql_query("SELECT * from tblvisit
WHERE tblvisit.PatientName = '".$StaffRec['Name']."'
ORDER BY tblvisit.Id desc limit 1");
After the condition
only you have to apply the order
.