TY_BCS_PHP_SLIP 13_2



Slip no. 13. Consider the following entities and their relationship.
Doctor ( doc_no, dname, address, city, area)
Hospital (hosp_no, hname, hcity)
Doctor-Hospital related with many-one relationship.
Create a RDB in 3NF for above and solve the following.
Using above database write a script in PHP to print the Doctor visiting to the hospital in tabular format. Accept hospital name from user[ Use PostgreeSQL]
HTML file :
<html>
<body>
<form action=slip13_2.php>
Enter Hospital Name :<input type=text name=a id=a><br>

<input type=submit value="DISPLAY" >
</form>
</body>
</html>

PHP file :
<?php
$con_string="host = localhost dbname=bcs_slips port=5432  user=postgres password=nrc";

$con = pg_connect($con_string);

$a = $_GET['a'];
echo $a;
echo "</br>";
$q = "select dname from doctor,hospital where hname='$a' and hospital.hosp_no = doctor.hosp_no;";

$rs = pg_query($con,$q) ;
if($rs)
{
echo "in";
while($row=pg_fetch_row($rs))
echo "$row[0]\n</br>";
}
pg_close();
?>

No comments:

Post a comment

Note: only a member of this blog may post a comment.