Jump to content

Counting The Number Of Categories?? How To??


jigsawsoul

Recommended Posts

Hey Guys

 

I'm not really sure where to start, but i have a number of products within my products table, which all fall under different types of categories. So i have two tables, products and categories which both have a relationship, so I can tell which products below in which categorie.

 

So i want to display a navigation of the categories and how many products are in that categorie.

 

e.g.

 

Apple Laptops (3)

Apple Desktops (9)

PC Laptops (4)

 

Etc...

 

does anyone have an idea on where to start, or how this would be created. Anything would be a good help..

 

Thanks. p.s. anymore information needed just ask.. :)

 

 

:shrug:

 

 

 

 

 

[attachment deleted by admin]

I have this code below it displays the categories in the navigation fine.

 

But where it says (0) i want to display the amount of products in my products.table where categories is equal to the id..

 

any ideas on how to do this?  :confused:

 

<?php

$result = "SELECT * FROM categories";
$result = mysql_query ($result) or die (mysql_error());
while($row = mysql_fetch_assoc($result)) 
{		
	$categories .= '
		<li><a href="categorie.php?id='.$row['id'].'">'.$row['categorie'].' (0)</a></li>
      	';
 }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.