Advertisement
Guest User

Untitled

a guest
Feb 16th, 2017
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "Armando";
  4. $password = "12345";
  5. $dbname = "actors";
  6.  
  7. // Create connection
  8. $conn = mysqli_connect($servername, $username, $password, $dbname);
  9. // Check connection
  10. if (!$conn) {
  11. die("Connection failed: " . mysqli_connect_error());
  12. }
  13.  
  14. $sql = "SELECT id, firstname, lastname, age";
  15. $result = mysqli_query($conn, $sql);
  16.  
  17. if (mysqli_num_rows($result) > 0) {
  18. // output data of each row
  19. while($row = mysqli_fetch_assoc($result)) {
  20. echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. Age: " . $row["firstname"]. ""<br>";
  21. }
  22. } else {
  23. echo "0 results";
  24. }
  25.  
  26. mysqli_close($conn);
  27. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement