Guest User

Untitled

a guest
Jun 2nd, 2018
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. $servername = "localhost";
  2. $username = "username";
  3. $password = "password";
  4. $dbname = "myDB";
  5.  
  6. // Create connection
  7. $conn = new mysqli($servername, $username, $password, $dbname);
  8. // Check connection
  9. if ($conn->connect_error) {
  10. die("Connection failed: " . $conn->connect_error);
  11. }
  12.  
  13. //$sql = "Sua Query";
  14. $sql = "SELECT * FROM Tabela"; //exemplo
  15. $result = $conn->query($sql);
  16.  
  17. if ($result->num_rows > 0) {
  18. while($row = $result->fetch_assoc()) {
  19.  
  20. }
  21. } else {
  22. echo "0 results";
  23. }
  24. $conn->close();
Add Comment
Please, Sign In to add comment