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]

Link to comment
Share on other sites

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>
      	';
 }

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.