1 <html>
2 <body>
3 <form action="" method="post">
4 Enter Reg No to be searched<input type="text" name="x"></br>
5 <input type="submit" value="Search"><input type="reset" value="clear">
6 </form>
7 </body></html>
8
9 <?php
10 $servername='localhost';
11 $username='root';
12 $password="";
13 $dbname='bsc';
14
15 $conn = mysqli_connect($servername, $username, $password,$dbname);
16
17 if (!$conn)
18 {
19 die("Connection failed:".mysqli_connect_error());
20 }
21 else if($_SERVER['REQUEST_METHOD']=="POST")
22 {
23 $regno=$_POST['x'];
24
25 $sql = "SELECT * FROM student WHERE regNo='$regno'";
26 $result = mysqli_query($conn, $sql);
27
28 if (mysqli_num_rows($result) > 0)
29 {
30 while($row = mysqli_fetch_assoc($result))
31 {
32 echo "Student Reg No:" . $row["regNo"]."</br>";
33 echo "Student name: " . $row["name"]."</br>";
34 echo "Student Age:" . $row["age"]."</br>";
35 echo "</br>";
36 }
37
38 }
39 else
40 {
41 echo "0 results";
42 }
43
44 }
45
46 ?>
47