Jump to content

problems with count??


jacko_162

Recommended Posts

i have a table with products, each product i add has its own catagory,

 

if i list the catagories like so;

 

<?

// Query to pull information from the "products" Database
$ret = mysql_query("SELECT * FROM $table1"); {

// Query to pull information from the "catagory" Database
$result = mysql_query("select * from $table13 order by view DESC");
while ($row = mysql_fetch_object($result)) {
?>
                <img src="images/arrow.gif"> <a href="products.php?catagory=<? echo $row->name; ?>"> <? echo $row->name; ?></a> (<? echo mysql_num_rows($ret);  mysql_free_result($ret);?>)<br>
                <? }} ?>

 

i want it to count the amount of products in each catagory;

 

for example;

 

Catagories;

> Fish (3)

> Corals (2)

> Inverts (1)

 

Still a newbie at this.

Link to comment
Share on other sites

Your code doesn't really make much sense to me. You are looping through results from whatever table is in $table13 to produce your links. Yet the number you echo is supposed to be the number of rows returned from another table($table1), so you would always end up with the same number on each category.

 

What is your table structure? Where are you trying to get the information from?

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.