Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2.     $servername = "localhost";
  3.     $username = "student";
  4.     $password = "robertson";
  5.     $dbname = "teams";
  6.  
  7.     $conn = new mysqli (
  8.         $servername,
  9.         $username,
  10.         $password,
  11.         $dbname
  12.     );
  13.  
  14.     if ($conn->connect_error) {
  15.         die("Oops! Couldn't connect: " . $conn->connect_error);
  16.     }
  17.  
  18.     $sql = "SELECT name, phone FROM tbStudent";
  19.     $result = $conn->query($sql);
  20.  
  21.     if ($result->num_rows > 0) {
  22.         // Create table
  23.         echo "<table style=\"border: 1px solid; text-align: center;\"><tr><th width=\"140px;\">Name</th><th width=\"140px;\">Phone</th></tr>";
  24.  
  25.         while ($row = $result->fetch_assoc()) {
  26.             echo "<tr><td>" .$row["name"]. "</td><td>" .$row["phone"]. "</td></tr>";
  27.         }
  28.  
  29.         // Close the table
  30.         echo "</table>";
  31.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement