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
https://forums.phpfreaks.com/topic/76260-problems-with-count/
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
https://forums.phpfreaks.com/topic/76260-problems-with-count/#findComment-387055
Share on other sites

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.