Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername= "localhost";
- $username= "root";
- $password="";
- $dbname="bit2018";
- //create connection
- $conn = mysqli_connect($servername, $username, $password, $dbname);
- //check connection
- if(!$conn)
- {
- die("Connection failed:" . mysqli_connect_error());
- }
- $sql = "SELECT * FROM students";
- $result = mysqli_query($conn,$sql);
- if(mysqli_num_rows($result)>0)
- {
- ?>
- <table border = "1" width ="600px" height = "500px">
- <tr>
- <th>S.No</th>
- <th>Full Name</th>
- <th>Roll No</th>
- <th>Contact</th>
- <th>Address</th>
- </tr>
- <?php
- //output data of each row
- $i=1;
- while($row = mysqli_fetch_assoc($result))
- {
- ?>
- <tr>
- <td><?php echo $i; $i++; ?></td>
- <td><?php echo $row['std_fname']." ".$row['std_lname'];?></td>td>
- <td><?php echo $row['std_roll'];?></td>td>
- <td><?php echo $row['std_contact'];?></td>td>
- <td><?php echo $row['std_address'];?></td>td>
- </tr>
- <?php
- }
- }
- else
- {
- ?>
- <tr>
- <td colspan ="5"> No Records Found</td>
- </tr>
- <?php
- }
- mysqli_close($conn);
- ?>
- </table>
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement