jacko_162 Posted November 6, 2007 Share Posted November 6, 2007 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. Quote Link to comment Share on other sites More sharing options...
revraz Posted November 6, 2007 Share Posted November 6, 2007 What is the { for here? $ret = mysql_query("SELECT * FROM $table1"); { Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted November 6, 2007 Share Posted November 6, 2007 try a count(fieldname) type of query it will be better for you tizag has a nice tutorial on it Quote Link to comment Share on other sites More sharing options...
jacko_162 Posted November 7, 2007 Author Share Posted November 7, 2007 i tried the count thing from tizag but cant get it to work. ??? Quote Link to comment Share on other sites More sharing options...
GingerRobot Posted November 7, 2007 Share Posted November 7, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.