Hey guys and gals, jsut having a bit of trouble with some code of mine, every time I search my database, now matter what I put it comes back saying it has found none, when I know that they are in there. I posted the code down below,
thanks coolman
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Comic Collectables - Search Results</title>
</head>
<body>
<h1>Comic Collectables - Search Results</h1>
<?
//Check that the form has been submitted
if ($POST) {
// Store form data in varibles
$form_series_name = $_POST['series_name'];
$form_comic_issue = $_POST['comic_issue'];
$form_comic_condition = $_POST['comic_condition'];
//trim the data field up
$form_comic_issue = trim($form_comic_issue);
//open a link to the data base
$link = mysqli_connect('localhost', 'username', 'pass, 'database');
//define query
$query = "
SELECT
comics.comic_id
series.series_name
comics.comics_issue
comics.comic_condition
comics.comic_price
FROM series, comics
WHERE series.comic_id = comics.series_id";
//restrictions for the search if any
if ($form_series_name !="") {
$query .= "AND series.series_name = '$form_series_name' ";
}
if ($form_comic_issue !="") {
$query .= "AND comics.comic_issue = '$form_comic_issue' ";
}
if ($form_comic_condition !="") {
$query .= "AND comics.comic_condition = '$form_comic_condition' ";
}
// Save the results
$result = mysqli_query($link, $query);
//set the number of rows
$number_of_rows = mysqli_num_rows($result);
//close the link
mysqli_close($link);
}
//if no records are retrieved
if ($number_of_rows == 0) {
echo <<<END
<p>There are no matching records in the database.
Use the Back button on your Web browser to return to
the previous page and try again.
</p>
END;
}
else {
//display the coloum headings
echo <<<END
<p>Search results are presented below</p>
<table border ="0">
<tr>
<th>ID Number</th>
<th>Series</th>
<th>Issue</th>
<th>Condition</th>
<th>Price</th>
</tr>
END;
//Assign each row a record
while ($row = mysqli_fetch_array($result)) {
$comic_id = $row['comic_id'];
$series_name = $row['series_name'];
$comic_issue = $row['comic_issue'];
$comic_condition = $row['comic_condition'];
$comic_price = $row['comic_price'];
//makes a new row for each record
echo <<<END
<tr>
<td>$comic_id</td>
<td>$series_name</td>
<td>$comic_issue</td>
<td>$comic_condition</td>
<td>$comic_price</td>
</tr>
END;
}
echo "</table>";
}
?>
</body>
</html>