Consider the following entities and their relationships
Student (Stud_id,name,class)
Competition (c_no,c_name,type)
Relationship between student and competition is many-many with attribute rank and
year. Create a RDB in 3NF for the above and solve the following.
Using above database write a script in PHP to accept a competition name from user
and display information of student who has secured 1st rank in that competition.
ex5setc2.html
<html>
<body>
<form method="post" action="ex5setc2.php">
Enter compitition name:
<input type="text" name="cname"><br>
<input type='submit' name='submit' value='submit'>
<input type='reset' name='reset' value='reset'>
</form>
</body>
</html>
ex5setc2.php
<?php
$str1=$_POST['cname'];
$conn_str="host=192.168.100.10 port=5432 dbname=tybcs8 user=tybcs8";
$conn=pg_connect("$conn_str");
if(!$conn)
{
echo"fail";
}
else
{
$q="select * from student1 where sid in(select sid from s_c where cno in(select cno from compitition where cname='$str1')and rank='1')";
$rs=pg_query($conn,"$q");
if(!$rs)
{
echo" an error<br>";
}
echo"<table border=2>";
echo"<tr>";
echo"<th>Sno</th>";
echo"<th>Student name</th>";
echo"<th>class</th>";
echo"</tr>";
while($row=pg_fetch_assoc($rs))
{
echo"<tr>";
echo"<td>$row[sid]</td>";
echo"<td>$row[sname]</td>";
echo"<td>$row[class]</td>";
echo"</tr>";
}
echo"</table>";
}
?>
0 Comments
If anyone has Doubts or suggestions please let me know