Guest User

Untitled

a guest
Jan 11th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.71 KB | None | 0 0
  1. <?php
  2. $hostname="localhost";
  3. $username="";
  4. $password="";
  5. $database="chewvall_books";
  6. mysql_connect($hostname,$username,$password);
  7. @mysql_select_db($database) or die ("Unable to select database");
  8. $db_select=mysql_select_db(chewvall_books);
  9. if(!$db_select){
  10.    die ("Could not connect to the database: <br />".mysql_error());
  11. }
  12. $query = "SELECT * FROM books NATURAL JOIN authors";
  13. $result = mysql_query( $query );
  14. if (!$result){
  15.    die ("Could not query the database: <br />". mysql_error());
  16. }
  17. while ($result_row = mysql_fetch_row($result)){
  18.     echo 'Title: '.$result_row[1] . '<br />';
  19.     echo 'Author: '.$result_row[4] . '<br />';
  20.     echo 'Pages: '.$result_row[2] . '<br />';
  21. }
  22. mysql_close();
  23. ?>
Add Comment
Please, Sign In to add comment