I have written a code for search . error i am getting is that it displays only search result of first 5 entries in a database whereas it is not showing the remaining entries in a database. Can anyone please tell me where i am doing mistake... Here is my code...
<head>
Search-RHMS
</head>
<body>
<form Name="theform" method= get>
<input type="text" name="User_Name" size= "10" maxlength="20"/>
<input type="submit" name="submit" value= "Search Patient"/>
</form>
<?php
error_reporting(E_ALL);
$db=mysql_connect('localhost','root','root');
if(!$db)
{
echo "Cannot connect to database";
}
$db_found=mysql_select_db('RHMS');
if (empty($_GET['User_Name']))
{
$UserName=False;
echo "Required field is empty";
}
else
{
$UserName=mysql_real_escape_string($_GET['User_Name']);
}
if ( $UserName)
{
$str="SELECT * FROM PAT_REG WHERE Name_User='".$UserName."'";
$result=mysql_query($str);
if(mysql_num_rows($result)==0)
{
echo "No record found";
}
else
{
$rows=mysql_fetch_array($result);
echo "<table border='1' cellspacing='2' cellpadding='2'>
<tr>
<th> ID</th>
<th> First Name</th>
<th> Last Name</th>
<th>City</th>
<th> Contact Num</th>
<th> User Name</th>
</tr>";
$kr= mysql_num_rows($result);
while($rows=mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$rows['id']."</td> ";
echo "<td> ".$rows['Name_First']."</td> ";
echo "<td> ".$rows['Name_Last']."</td> ";
echo "<td> ".$rows['City']."</td> ";
echo "<td> ".$rows['Contact_num']."</td> ";
echo "<td> ".$rows['Name_User']."</td></br>";
echo "</tr>";
}
echo " </table>";
}
}
?>
</Body>