Hi me again, back for more advice,
The booklist.php script now has the following form:
<form action="booklist_filter.php" method="get" name="category" target="_self" class="bodytext" id="category">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="93%"><select name="category" class="bodytext"onChange="submit()">
<option value="all" <?php if (!(strcmp("", "category"))) {echo "SELECTED";} ?>>All</option>
<?php
do {
?>
<option value="<?php echo $row_category['category_id']?>"<?php if (!(strcmp($row_category['category_id'], "category"))) {echo "SELECTED";} ?>><?php echo $row_category['category']?></option>
<?php
} while ($row_category = mysql_fetch_assoc($category));
$rows = mysql_num_rows($category);
if($rows > 0) {
mysql_data_seek($category, 0);
$row_category = mysql_fetch_assoc($category);
}
?>
</select>
</td>
<td width="7%"><div align="right"><a href="index.htm" target="_self"><img src="images/Previous.gif" alt="Back to home page" width="14" height="13" border="0"></a></div></td>
</tr>
</table>
</form>
I have rewitten the book_filter.php script as follows:
<?php require_once('../Connections/Chandos.php'); ?>
<?php
$currentPage = $_SERVER["PHP_SELF"];
$maxRows_record_filter = 4;
$pageNum_record_filter = 0;
if (isset($_GET['pageNum_record_filter'])) {
$pageNum_record_filter = $_GET['pageNum_record_filter'];
}
$startRow_record_filter = $pageNum_record_filter * $maxRows_record_filter;
$colname_record_filter = "1";
if (isset($_GET['category'])) {
$colname_record_filter = (get_magic_quotes_gpc()) ? $_GET['category'] : addslashes($_GET['category']);
}
if ($category == "all")
{
mysql_select_db($database_Chandos, $Chandos);
$query_record_filter = sprintf("SELECT * FROM chandos_books WHERE category = '$s' ORDER BY 'book_title'", $colname_record_filter);
$query_limit_record_filter = sprintf("%s LIMIT %d, %d", $query_record_filter, $startRow_record_filter, $maxRows_record_filter);
$record_filter = mysql_query($query_limit_record_filter, $Chandos) or die(mysql_error());
$row_record_filter = mysql_fetch_assoc($record_filter);
}
else
mysql_select_db($database_Chandos, $Chandos);
$query_record_filter = sprintf("SELECT * FROM chandos_books WHERE category = '%s' ORDER BY 'book_title'", $colname_record_filter);
$query_limit_record_filter = sprintf("%s LIMIT %d, %d", $query_record_filter, $startRow_record_filter, $maxRows_record_filter);
$record_filter = mysql_query($query_limit_record_filter, $Chandos) or die(mysql_error());
$row_record_filter = mysql_fetch_assoc($record_filter);
if (isset($_GET['totalRows_record_filter'])) {
$totalRows_record_filter = $_GET['totalRows_record_filter'];
} else {
$all_record_filter = mysql_query($query_record_filter);
$totalRows_record_filter = mysql_num_rows($all_record_filter);
}
$totalPages_record_filter = ceil($totalRows_record_filter/$maxRows_record_filter)-1;
mysql_select_db($database_Chandos, $Chandos);
$query_Cat_filter = "SELECT * FROM chandos_book_category";
$Cat_filter = mysql_query($query_Cat_filter, $Chandos) or die(mysql_error());
$row_Cat_filter = mysql_fetch_assoc($Cat_filter);
$totalRows_Cat_filter = mysql_num_rows($Cat_filter);
$queryString_record_filter = "";
if (!empty($_SERVER['QUERY_STRING'])) {
$params = explode("&", $_SERVER['QUERY_STRING']);
$newParams = array();
foreach ($params as $param) {
if (stristr($param, "pageNum_record_filter") == false &&
stristr($param, "totalRows_record_filter") == false) {
array_push($newParams, $param);
}
}
if (count($newParams) != 0) {
$queryString_record_filter = "&" . htmlentities(implode("&", $newParams));
}
}
$queryString_record_filter = sprintf("&totalRows_record_filter=%d%s", $totalRows_record_filter, $queryString_record_filter);
?>
When I run the booklist.php script with the "all" option selcted it return zero records.
Can you spot where I have gone wronge.
Thanks for all your time.
Kind regards, keep safe and well.
Dereck