This question already has an answer here:
I'm having a problem with retrieving data,
I have two files **list_item.php**
and **mysql_con_links.php**
My mysql_con_links.php
has a table with book titles
and view details
with a link to view more details.
When I click on view more details i get this error:
Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/ob219/public_html/three/list_item.php on line 10
My **list_item.php**
code:
<?php
include 'library/connect.php';
$book_id =$_GET['id'];
$result = mysql_query("SELECT * FROM Books WHERE book_id = '$book_id'");
echo "<table border = '1'><tr><th>Title</th><th>Author</th><th>Category</th></tr>";
while($row = mysql_fetch_array($result)) // !!!problem here!!!
{
echo "<tr>";
echo "<td>" .$row['Title']. "</td>";
echo "<td>" .$row['Author']. "</td>";
echo "<td>" .$row['Category']. "</td>";
echo "</tr>";
}
echo "</table>";
include 'library/close.php';
?>
<a href="mysql_con_links.php">Back</a>
my **mysql_con_links.php**
code
<?php
include 'library/connect.php';
$result = mysql_query("SELECT * FROM `Books` ORDER BY `Author` DESC");
echo "<table border='1'>
<tr><th>Title</th><th>View Details</th></tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>".$row['Title']."</td>";
?>
<td><a href="list_item.php?id=<? echo $row['book_id'] ?>">view</a></td>
<?php
echo "</td>";
}
echo "</table>";
include 'library/close.php';
?>
</div>