infojunkie243

newquery.php

Mar 17th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.59 KB | None | 0 0
  1. <?php
  2. //Step1
  3.  $db = mysqli_connect('localhost','webcrawler','secret','webcrawler')
  4.  or die('Error connecting to MySQL server.');
  5. ?>
  6.  
  7. <html>
  8.  <head>
  9.  </head>
  10.  <body>
  11.  <h1>PHP connect to MySQL</h1>
  12.  
  13.  <?php
  14. //Step2
  15. $query = "SELECT * FROM document";
  16. mysqli_query($db, $query) or die('Error querying database.');
  17.  
  18. $result = mysqli_query($db, $query);
  19. $row = mysqli_fetch_array($result);
  20.  
  21. while ($row = mysqli_fetch_array($result)) {
  22.  echo $row['url'] . ' ' . $row['title'] . ': ' . $row['text'] . ' ' . $row['links'] .'<br />';
  23. }
  24.  
  25. //Step 4
  26. mysqli_close($db);
  27. ?>
  28.  
  29. </body>
  30. </html>
Add Comment
Please, Sign In to add comment