Doctor-Hospital Create A RDB In 3NF | PHP - IProgramX

Q: 2) 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>
<center>
<form method=GET action=a5a2.php>
Hospital Name : <input type=text name=hname>
<input type=submit value=Submit>
</form>
</center>
</html>

PHP Function:
NOTE: PHP function is saved as "a5a2.php"


<?php

$hname = $_GET['hname'];

$db = pg_connect("host=localhost dbname=Slips user=hp password= ");
if($db)
{
$query = "select * from doc where dno in(select dno from doc_hosp where hno in(select hno from hosp where
hname='$hname'))";
$resultSet = pg_query($db,$query);
echo "<h1>Doctor from hospital $hname are ...</h1>";
echo "<table style=height:400;width:400; border=3>";
echo "<tr><th>Dno</th>";
echo "<th>Name</th>";
echo "<th>Address</th>";
echo "<th>City</th></tr>";
while(($row = pg_fetch_array($resultSet)) != null)
{
echo "<tr><td>".$row['dno']."</td>";
echo "<td>".$row['dname']."</td>";
echo "<td>".$row['addr']."</td>";
echo "<td>".$row['city']."</td></tr>";
}
echo "</table>";
}

?>

Post a Comment

0 Comments