Well, my code works when the selected row exists in the database, it works perfect. But the problem is when I am selecting a data that doesn't exist at all. It gives me an error that my variables are undefined.
This is the scripting:
<?php
include('Nethost.php');
$patient = $_POST['patientid'];
$diagnosisid = $_POST['diagnosis'];
$pname = $_POST['patientname'];
$d = $_POST['diagnosis'];
$query = mysql_query("select objective from soapie WHERE patientid='$patient' AND subjective='$diagnosisid' LIMIT 1");
while($rows = mysql_fetch_assoc($query))
{
if($rows==NULL)
{
echo "No data";
}
else
{
$objective = $rows['objective'];
}
}
?>
I am displaying it input type text..
<table style="margin-left:auto; margin-right:auto">
<tr>
<td>Objective</td>
</tr>
<tr>
<td><input ID="txtobjective" name="objective" value="<?php echo "" .$objective. ""; ?>" type="text" /><br></td>
</tr>
</table>
I think this is a common problem and I can't even solve it. I just got back from coding using PHP. Can someone suggest me a good practice to handle this kind of problems. Thanks in advance.