scar5308 Posted May 14, 2007 Share Posted May 14, 2007 I am trying to adapt part of a script. At present, it show the names of subcategories of items for sale but I would like it to show next to the subcategory, the number of items for sale without the visitor having to click on the link only to find there are no items in this subcategory. I have it working after a fashion but it also shows 1 item in the subcategories where there are either 0 items or 1. With the subcategories with 2 or more items there is no problem. I would like the subcategories to only show the number of items available in that subcategory if there are any, otherwise it could show either 0 or nothing. I think I should be using an array and not an if else statement as I am trying to evaluate numbers but I am not too sure. My code reads: if (num_ads == 0) /*mod to show number of items*/ echo '<a href="'.$link.'">'.$row->name. ' ('.$row-> num_ads. ' items)';'</a>'; I tried changing the if (num_ads == 0) to 1 and all the rows disappeared. I added an else statement after but just got a parse error. I would be grateful for some direction here! Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/51331-if-or-array-please-help/ 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.