Advertisement
Guest User

Untitled

a guest
Mar 18th, 2017
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. <?php
  2. //Step 1
  3. $db = mysqli_connect('172.24.1.64', 'root', '', 'hospital') or die('Error connecting to MySQL server.');
  4. $dbhost = "localhost";
  5. $dbuser = "root";
  6. $dbpass = "";
  7. $dbname = "hospital";
  8. $db = mysqli_connect($dbhost, $dbuser, $dbpass) or die("dbconn");
  9. mysql_select_db($dbname, $db) or die("mysql");
  10. ?>
  11.  
  12. <html>
  13. <head>
  14. </head>
  15. <body>
  16. <h1>
  17. PHP connect to MySQL
  18. </h1>
  19. <?php
  20. //Step 2
  21. $query = "SELECT * FROM patients;";
  22. mysqli_query($db, $query) or die('Error querying database.');
  23.  
  24. $result = mysqli_query($db, $query);
  25. $row = mysqli_fetch_array($result);
  26.  
  27. while($row = mysqli_fetch_array($result)){
  28. $id = $row['id'];
  29. $patientname = $row['patient_name'];
  30. $checkindate = $row['check_in_date'];
  31. $roomnumber = $row['room_number'];
  32. $bednumber = $row['bed_number'];
  33. $notes = $notes['notes'];
  34. echo "$id $patientname $checkindate $roomnumber $bednumber $notes";
  35. }
  36. ?>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement