Advertisement
Asome7

For Pio this is the one

Dec 5th, 2016
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $password = "password";
  5. $dbname = "myDB";
  6. $id = mysql_result(mysql_query("SELECT id FROM games LIMIT 1"),0);
  7.  
  8. // Create connection
  9. $conn = new mysqli($servername, $username, $password, $dbname);
  10. // Check connection
  11. if ($conn->connect_error) {
  12.     die("Connection failed: " . $conn->connect_error);
  13. }
  14.  
  15.  
  16. $sql = "SELECT id, firstname, lastname FROM MyGuests";
  17. $result = $conn->query($sql);
  18.  
  19.  
  20. if ($result->num_rows > 0) {
  21.     // output data of each row
  22.     while($row = $result->fetch_assoc()) {
  23.         echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
  24.     }
  25. } else {
  26.     echo "0 results";
  27. }
  28. $conn->close();
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement