Advertisement
Guest User

Untitled

a guest
Sep 7th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. <?php
  2. //Set database access credentials
  3. $name = 'moris';
  4. $user = 'root';
  5. $password = '';
  6. $host = 'localhost';
  7.  
  8. //Set table name
  9. $tname = 'users';
  10.  
  11. /*Open the connection to our database use the info from the config file.*/
  12. $link = mysql_connect($host, $user, $password);
  13.  
  14. if (!$link) {
  15. die('Could not connect: ' . mysql_error());
  16. }
  17.  
  18. $sql = "SELECT * FROM users";
  19.  
  20. $results = mysql_query($sql);
  21.  
  22. if (!$results) {
  23. die('Invalid query: ' . mysql_error());
  24. }
  25.  
  26. echo '<h3>Users Table</h3>';
  27.  
  28. while($result = mysql_fetch_array( $results )){
  29. echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">';
  30. echo '<p>Name: ' . $result['name'] . '</p>';
  31. echo '<p>Email: ' . $result['email'] . '</p>';
  32. echo '<p>Bio: ' . $result['bio'] . '</p>';
  33. echo '<p>Interest: ' . $result['interest'] . '</p>';
  34. echo '</div>';
  35. }
  36.  
  37. $sql = "SELECT * FROM newuser WHERE interest = 'php' ORDER BY name DESC";
  38.  
  39. $results = mysql_query($sql);
  40.  
  41. if (!$results) {
  42. die('Invalid query: ' . mysql_error());
  43. }
  44.  
  45. echo '<h3>Users2 Table</h3>';
  46.  
  47. while($result = mysql_fetch_array( $results )){
  48. echo '<div style="border: 1px solid #e4e4e4; padding: 15px; margin-bottom: 10px;">';
  49. echo '<p>Name: ' . $result['name'] . '</p>';
  50. echo '<p>Email: ' . $result['email'] . '</p>';
  51. echo '<p>Bio: ' . $result['bio'] . '</p>';
  52. echo '<p>Interest: ' . $result['interest'] . '</p>';
  53. echo '</div>';
  54. }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement