Guest User

Untitled

a guest
Dec 10th, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <!-- booklist.php -->
  2. <?php
  3. $dbuser='root';
  4. $dbpass='your_mysql_root_password';
  5. $dbhost='localhost';
  6.  
  7. $conn=mysql_connect($dbhost, $dbuser, $dbpass);
  8. if (!$conn) die("<h3><font color=red>You must install MySQL.</font></h3>");
  9. $db_selected=mysql_select_db("books", $conn);
  10. if (!$db_selected)
  11. {
  12. print("<h3><font color=red>Database does not exist.</font></h3>");
  13. }
  14. else
  15. {
  16. $r = mysql_query("SELECT * FROM book_table", $conn);
  17. }
  18. if (!$r)
  19. {
  20. print("<h3><font color=red>book_table does not exist.</font></h3>");
  21. }
  22. else
  23. {
  24. print("<h2><font color=Blue>Books in your_name Library</font></h2>
  25. <table border>
  26. <tr><b><Th>ID<Th>Author</Th><Th>Title</Th><Th>Publisher</Th><Th>Year</Th><Th>Pages</Th><Th>Category</Th><Th>Date read</Th><Th>Evaluation</Th><Th>Location</Th></b></tr>");
  27. while ($row = mysql_fetch_array($r))
  28. {
  29. print("<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td><td>$row[3]</td><td>$row[4]</td><td>$row[5]</td><td>$row[6]</td><td>$row[7]</td><td>$row[8]</td><td>$row[9]</td>");
  30. }
  31. }
  32. print("</table>");
  33. mysql_close($conn);
  34. print("<p></p>");
  35. print("<a href=index.htm>Return</a> to menu.");
  36. print('</center>');
  37. ?>
Add Comment
Please, Sign In to add comment