SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Feb 2003
    0 Post(s)
    0 Thread(s)

    Dynamic Image Map & Links

    Hi All,

    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.

    Here are the pages:

    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.


    If I only had a brain.

  2. #2
    SitePoint Wizard
    Join Date
    Jan 2004
    3rd rock from the sun
    0 Post(s)
    0 Thread(s)
    nice map.

    To save anyone else clicking around forever, and pick missouri, MO.

    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.

    Does that help?


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts