Solution:
<html>
<body>
<form action="s28.php" method="POST">
<table border=1>
<tr>
<td>Enter teacher's name : </td>
<td> <input type="text" name="tname"></td>
</tr>
<tr><td></td><td><input type="submit" name="submit" value="Submit"></td></tr>
</form>
</body>
</html>
S28.php
<?php
$database="archana2";
$con =mysqli_connect("localhost","root" ,"");
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db ($con,"$database");
$tname=$_POST['tname'];
echo $query="select sname,subject from student,s_t,teacher where student.sno=s_t.sno and teacher.tno=s_t.tno and tname='".$tname."'";
$result=mysqli_query($con,$query);
if(!$result)
{
die("An error occured...");
}
echo '<table>
<tr>
<th>Sname</th>
<th>Subject</th>
</tr>';
while($row=mysqli_fetch_array($result))
{
echo'
<tr>
<td>'.$row[0].'</td>
<td>'.$row[1].'</td>
</tr>';
}
echo '</table>';
mysqli_close($con);
?>
0 Comments