TY_BCS_PHP_SLIP 9_2




Slip no. 9. Consider the following entities and their relationship.
Student ( stud_id, name, class)
Competition(c_no,c_name, type)
a) Relationship between student and competition In many-many with attributes rank and year.
b) Create a RDB in 3NF for above and solve the following.
c) Using above database write a script in PHP to accept a competition from user and display information of student who has secured 1st rank in that competition.
HTML file :
<html>
<body>
<form action=slip9_2.php>
Enter Compitition 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 student.stud_id,sname,class from student,competition,stud_copm  where cnme='$a' and student.stud_id=stud_copm.stud_id and competition.c_no=stud_copm.c_no;";
$rs=pg_query($con,$q) or die("Cannot Execute query");
while($row=pg_fetch_row($rs))
echo "$row[0] $row[1] $row[2]\n</br>";

pg_close();
?>


No comments:

Post a Comment

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