Hi Guys.
Ive got a small problem where I'm trying to display rows from my DB
Here is the code that I'm currently using:
<?php
$results = $sqli = ("SELECT * FROM `books` ORDER BY `ISBN` ASC");
if ($results) {
//fetch results set as object and output HTML
while($obj = $results->fetch_object())
{
echo '<div class="book">';
echo '<form method="post" action="cart_update.php">';
echo '<div class="book-thumb"><img src="images/'.$obj->BookImage.'"></div>';
echo '<div class="book-content"><h3>'.$obj->Title.'</h3>';
echo '<div class="book-desc">'.$obj->BookDesc.'</div>';
echo '<div class="book-info">';
echo 'Price '.$currency.$obj->Price.' | ';
echo 'Qty <input type="text" name="product_qty" value="1" size="3" />';
echo '<button class="add_to_cart">Add To Cart</button>';
echo '</div></div>';
echo '<input type="hidden" name="ISBN" value="'.$obj->ISBN.'" />';
echo '<input type="hidden" name="type" value="add" />';
echo '<input type="hidden" name="return_url" value="'.$current_url.'" />';
echo '</form>';
echo '</div>';
}
}
?>
I keep getting the following error :
( ! ) Fatal error: Call to a member function fetch_object() on a non-object in C:\wamp\www\books.php on line 26
Line 26 is: while($obj = $results->fetch_object())
Any idea on what ive done wrong?
Thanks!