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
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.