I am working on a appointment management website. I have designed a page for arranging an appointment (inserting in database) and its working fine. Now i want to view a existing appointment (view/fetch from database) and even modify if needed (updating). And i am facing an error in existing appointment.
here is the code for existing appointment:
<?php
mysql_connect("localhost", "root", "") or die("Could not connect.");
mysql_select_db("appointo") or die("could not find db.");
if(isset($_POST['uname'])){
$searchq = $_POST['uname'];
$searchq = preg_replace("#[^0-9a-z]#i","",$searchq);
$query = mysql_query("SELECT * FROM appointments WHERE username LIKE '$searchq'") or die("could not search.");
$count = mysql_num_rows($query);
while($row = mysql_fetch_array($query)){
$name = $row['name'];
$doctorname = $row['doctorname'];
$purpose = $row['purpose'];
//$oname = '<div>'.$name.'</div>';
//$odname = '<div>'.$doctorname.'</div>';
//$opurpose = '<div>'.$purpose.'</div>';
}
}
?>
<form method="POST">
<input type="text" name="uname" placeholder="Seach using Name.." />
<input type="search" name="search" value="Search" /><br><br>
Output:
<?php
//$name=$_SESSION['name'];
//$doctorname=$_SESSION['doctorname'];
//$purpose=$_SESSION['purpose'];
echo "'Name:''.$name'";
echo "Doctor Name:".$doctorname;
echo "Purpose:".$purpose;
?>
</form>
Still not able to fetch data. I want that if someone enters a username (say, nichani) which i already have stored in my database. And clicks on search button, he should see below output as:
Name: Nishant Nichani
Doctor Name: Dr. A
Purpose: General Checkup
help me. .fetch it from database.