21. Consider the following entities and their relationships
Doctor (doc_no,
doc_name, address, city, area)
Hospital (hosp_no,
hosp_name, hosp_city)
Doctor and Hospital are related with
many-many relationship
Create a RDB in 3 NF for the above and solve
following
Using above database, write a PHP script
which accepts hospital name and print information about doctors visiting /
working in that hospital in tabular format.
Html file :
<html>
<body>
<form
action="slip_21.php" method="get">
Enter
the Name Of Hospital : <input type=text name=hosp><br>
<input
type=submit value=SUBMIT>
</form>
</body>
<html>
Php file :
<?php
$hosp=$_GET['hosp'];
$con=mysql_connect("localhost","root","");
$d=mysql_select_db("bca_programs",$con);
$q=mysql_query("select
doctor.doc_no,doc_name,address,city,area from doctor,hospital,doc_hosp where
hosp_name='$hosp' and doc_hosp.doc_no=doctor.doc_no and
doc_hosp.hosp_no=hospital.hosp_no");
echo "<tr><td>Doctor
no--</td><td>Doctor Name--</td><td>Address--</td><td>city--</td><td>Area</td></tr>";
while($row=mysql_fetch_array($q))
{
echo "<br><tr><td>".$row[0]." | </td><td>".$row[1]." | </td><td>".$row[2]." | </td><td>".$row[3]." |</td><td>".$row[4]." |</td></tr>";
}
mysql_close();
?>
No comments:
Post a Comment
Note: only a member of this blog may post a comment.