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.
ex5seta2.html
<html>
<body>
<form method="post" action="ex5seta2.php">
Enter hospital name:
<input type="text" name="hname"><br>
<input type='submit' name='submit' value='submit'>
<input type='reset' name='reset' value='reset'>
</form>
</body>
</html>
ex5seta2.php
<?php
$hosp=$_POST['hname'];
$db=pg_connect("host=192.168.100.10 user=tybcs8 dbname=tybcs8");
if(!$db)
{
echo "An error occured";
exit;
}
else
{
echo "successfully connected";
$result=pg_query($db,"select * from doctor where dno in(select dno from d_h where hno in(select hno from hospital where hname='".$hosp."'))");
if(!$result)
{
echo "An error occured";
exit;
}
echo "<table border=1><th>doc no</th><th>doc name</th><th>add</th><th>city</th><th>area</th>";
while($row=pg_fetch_array($result))
{
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td></tr>";
}
echo "</table>";
}
pg_close($db);
?>
0 Comments
If anyone has Doubts or suggestions please let me know