Skip to main content
Inspiring
September 26, 2012
Answered

how to exclude a category from a product list

  • September 26, 2012
  • 10 replies
  • 1239 views

I have all the products selected from the DB

$maxRows_Recordset1 = 56;

$pageNum_Recordset1 = 0;

if (isset($_GET['pageNum_Recordset1'])) {

  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];

}

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_beau, $beau);

$query_Recordset1 = "SELECT * FROM beauProd ORDER BY name ASC";

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);

$Recordset1 = mysql_query($query_limit_Recordset1, $beau) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {

  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];

} else {

  $all_Recordset1 = mysql_query($query_Recordset1);

  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);

}

$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

but i have a category ID 21 that i dont want showing in with all the other products

what do i have to do

thanks in advance

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer bregent

ok thank you. i will have a look on the net to see how to filter out.

thanks again


Jon, this is just basic SQL.

If you wanted to include only rows from that category, you would do:

SELECT * FROM beauProd WHERE categoryID = 21 ORDER BY name ASC";

What do you think you need to change in the WHERE clause so that it excludes categoryID 21?

10 replies

Participating Frequently
September 27, 2012

If category is a column in the beauProd table, then just exclude it in the WHERE clause.

Inspiring
September 27, 2012

thought the where clause was to include not exclude?

Participating Frequently
September 27, 2012

Of course not. You can combine conditions in the WHERE clause to filter IN or filter OUT any values you like.