Hello,
I have a little problem which I think is because of the php aspect of my database...
My code:
<?
// connect to MySQL server and select database
@mysql_connect("localhost", "--", "--")
or die("Could not connect to MySQL server!");
@mysql_select_db("basichy_ict") or die("Could not select company database!");
$keyword = $_POST["keyword"];
// form and execute query statement
$query = "SELECT id, title, author, price, genre, stock
FROM books WHERE $title = '$keyword'";
$result = mysql_query($query);// If no matches found, display message and redisplay form
if (mysql_num_rows($result) == 0) :
print "Sorry, but no matches were found. Please try your search again:";
// matches found, therefore format and display results
else :
// format and display returned row values.
list($id, $title, $author, $price, $genre, $stock) = mysql_fetch_row($result);
print "<h3>Stock Information:</h3>";
print "<b>ID:</b> $id <br>";
print "<b>title:</b> $title <br>";
print "<b>Author:</b> <a href=\"mailto:$email\">$email</a> <br>";
print "<b>Price:</b> $price <br>";
print "<b>Genre:</b> $genre <br>";
print "<b>Stock:</b> $stock <br>";
// form and execute 'orders' query
$query = "SELECT id, title, author, price, genre, stock
FROM books WHERE id = '$id'
ORDER BY quantity DESC";
$result = mysql_query($query);
print "<table border = 1>";
print "<tr><th>ID</th><th>Title</th><th>Author</th><th>Price</th><th>Genre</th><th>Stock</th></tr>";
// format and display returned row values.
while (list($id,$title,$author,$price,$genre,$stock) = mysql_fetch_row($result)):
print "<tr>";
print "<td>$id</td><td>$title</td><td>$author</td><td>$price</td><td>$genre</td><td>$stock</td>";
print "</tr>";
endwhile;
print "</table>";
endif;
?>
The output:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/basichy/public_html/ict/search.php on line 12
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/basichy/public_html/ict/search.php on line 17
Stock Information:
ID:
title:
Author:
Price:
Genre:
Stock:
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/basichy/public_html/ict/search.php on line 33
ID Title Author Price Genre Stock
Any ideas?