Created
December 7, 2017 20:20
-
-
Save Random-Black-Coder/6e5a011eb8e9259a7b3770e364640e87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- booklist.php --> | |
<?php | |
$dbuser='root'; | |
$dbpass='your_mysql_root_password'; | |
$dbhost='localhost'; | |
$conn=mysql_connect($dbhost, $dbuser, $dbpass); | |
if (!$conn) die("<h3><font color=red>You must install MySQL.</font></h3>"); | |
$db_selected=mysql_select_db("books", $conn); | |
if (!$db_selected) | |
{ | |
print("<h3><font color=red>Database does not exist.</font></h3>"); | |
} | |
else | |
{ | |
$r = mysql_query("SELECT * FROM book_table", $conn); | |
} | |
if (!$r) | |
{ | |
print("<h3><font color=red>book_table does not exist.</font></h3>"); | |
} | |
else | |
{ | |
print("<h2><font color=Blue>Books in your_name Library</font></h2> | |
<table border> | |
<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>"); | |
while ($row = mysql_fetch_array($r)) | |
{ | |
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>"); | |
} | |
} | |
print("</table>"); | |
mysql_close($conn); | |
print("<p></p>"); | |
print("<a href=index.htm>Return</a> to menu."); | |
print('</center>'); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment