Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_host = '127.0.0.1';
- $db_user = 'root';
- $db_pass = 'root';
- $db_name = 'college';
- $conn = mysqli_connect($db_host, $db_user, $db_pass, $db_name);
- if($conn === false){
- die('Error while connecting:' . mysqli_connect_error());
- }
- $post = $_POST;
- $sql = "SELECT * FROM students";
- if($result = mysqli_query($link, $sql)){
- if(mysqli_num_rows($result) > 0){
- echo "<table>";
- echo "<tr>";
- echo "<th>ID</th>";
- echo "<th>First Name</th>";
- echo "<th>Last Name</th>";
- echo "<th>Email</th>";
- echo "</tr>";
- while($row = mysqli_fetch_array($result)){
- echo "<tr>";
- echo "<td>" . $row['id'] . "</td>";
- echo "<td>" . $row['first_name'] . "</td>";
- echo "<td>" . $row['last_name'] . "</td>";
- echo "<td>" . $row['email'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- mysqli_free_result($result);
- } else {
- echo "Sorry! No records found.";
- }
- } else {
- echo "Error while executing $sql. " . mysqli_error($link);
- }
- // Close connection
- mysqli_close($link);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement