Jump to content

if or array? please help!


scar5308

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/51331-if-or-array-please-help/
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.