StudCom.html
<html>
<body>
<form
method="get" action="studcomp.php">
<fieldset>
            <legend>Enter Competition Name
:</legend><br>
<input
type="text" name="cnm"><br><br>
</fieldset>
<div
align="center">
<input
type="submit" value="Show Result">
</div>
</form>
</body>
</html>
StudCom.php
<?php
        $cnames=$_GET['cnm'];
                        $hn="localhost";
                        $un="root";
                        $pass="";
                        $db="students";
                        $link=mysqli_connect($hn,$un,$pass,$db);
            if(!$link)
            {
                        die('Connection
Failed:'.mysqli_error());
            }
            //$sql="SELECT * FROM student
WHERE CNo IN (SELECT CNo FROM competition WHERE CName =
'".$cname."')";
            $sql="select * from
student,competition,studcomp where student.Sid=studcomp.Sid and
competition.CNo=studcomp.CNo and rank='1' and
CName='".$cnames."'";
            $res=mysqli_query($link,$sql);           
            if(mysqli_num_rows($res)>0)
            {
                        while($row=mysqli_fetch_assoc($res))
         {
                                    echo"Stud
No : ".$row['Sid']."<br>"."  Name  :
".$row['SName']."<br>";
                                    echo"Class
: 
".$row['SClass']."<br>";
                                    echo"--------------------------"."<br>";
                        }
            }
            else
            {
                        echo"error";
            }
            mysqli_close($link);
?>

