sheena2994

Untitled

Mar 21st, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. server with default setting (user 'root' with no password) */
  2. $link = mysqli_connect("localhost", "root", "codebrew", "collegeHub");
  3.  
  4. // Check connection
  5. if($link === false){
  6. die("ERROR: Could not connect. " . mysqli_connect_error());
  7. }
  8.  
  9. // Attempt select query execution
  10. $sql = "SELECT * FROM questions";
  11. if($result = mysqli_query($link, $sql)){
  12. if(mysqli_num_rows($result) > 0){
  13.  
  14. while($row = mysqli_fetch_array($result)){
  15. echo "<tr>";
  16. echo "<td>" . $row['id'] . "</td>";
  17. echo "</tr>";
  18. }
  19. echo "</table>";
  20. // Free result set
  21. mysqli_free_result($result);
  22. } else{
  23. echo "No records matching your query were found.";
  24. }
  25. } else{
  26. echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
  27. }
  28.  
  29. // Close connection
  30. mysqli_close($link);
Add Comment
Please, Sign In to add comment