I am creating a vacation directory targeted toward international visitors. I have catagories broken down by state and industry. When a visitor clicks on the industry they are taken to a map of the US. this is a huge image map. Here they can select the state they are looking for. The problem is that not every state has a listing. Thus you could click on numerous states before you see a listing. So how can I get the links to appear if there is a listing for that state and not appear if there is not. I know I could do a bunch of IF-THEN statements but it seems there should be a better way.
Click under resources header to see a different industry.
Note: I am using PHP and MySQL. I have each industry in its own table and a list of states and industry codes in their own tables. There are really only two files, the map page and the listing page.
Forget the map for a moment, mind you thats what made me look at your post, dynamic image map? interesting.
As an excersise , you see the text links at the foot of the map, how about that said
on events
"Missouri (0 events)" and wasn't clickable, thatd be a start wouldnt it?
You could for example do an sql select and count the number of events, as you database loops thru the results
[say your events are being brought back in a $row['ID_CNT'] format ]
//in the loop
echo $row['ID_CNT'] ? '('.$row['ID_CNT'].')' : '(0 events)' ;
//
Now adapt that to show the link, if its no results, then dont write <a href= etc.
Thats an example of using a ternary operator to save nesting ifs and {}, which I understand was part of your Q.
Bookmarks