Slip 30 - C) Considerer 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.

Solution:


Html file :


<html>
<body>

<form action="slip_13.php" method="get">
Enter the name of competition  :  <input type=text name=cname><br>
<input type=submit value=SUBMIT>
</form>
</body>
<html>

Php file :


<?php
            $c_name   =   $_GET['cname'];

            $con   =   mysql_connect("localhost","root","");
            $d   =   mysql_select_db("bca_programs",$con);
            $q   =   mysql_query("select student_slip_13.stud_id,stud_name,stud_class from student_slip_13,compitition_slip_13,sc_slip_13 where student_slip_13.stud_id=sc_slip_13.stud_id and sc_slip_13.c_no=compitition_slip_13.c_no and c_name='$c_name' and rank=1");

            echo "<table>";
            echo "<tr><td>Student Id   |</td><td>Student Name   |</td><td>Student Class</td></tr>";
           
            while($row   =   mysql_fetch_array($q))
            {
                        echo "<tr><td>".$row[0]."</td><td>".$row[1]."</td><td>".$row[2]."</td></tr>";
            }
           
            echo "</table>";

            mysql_close();

?>

Email This
BlogThis!
Share to Twitter
Share to Facebook
Share to Pinterest

Post a Comment

0 Comments