Display if something is from a checkbox multi value list

5 posts by 2 authors in: Forums > CMS Builder
Last Post: October 11, 2009   (RSS)

By (Deleted User) - October 8, 2009 - edited: October 9, 2009

Hello,

I am building a site that has a number of tours. I would like to include a flag for each of the countries the tour travels through.

I previously used:

<?php if ($guided_tourRecord['tour_location'] == 'uk'): ?>
<span>This is some flag html for the uk</span>
<?php elseif ($guided_tourRecord['tour_location'] == 'us'): ?>
<span>This is some flag html for the us</span>
<?php else: ?><?php endif ?>


That was fine when I used a pulldown list where you could only select one country. How would I make this list 'if' from the checkboxes multi value list?

Thanks Jono

Re: [jonoc73] Display if something is from a checkbox multi value list

By Chris - October 11, 2009

Hi Jono,

You can use the same technique from [url http://www.interactivetools.com/forum/gforum.cgi?post=74818#74818]this post[/url].

Alternately, if all your countries are going to display the same HTML but with a different IMG SRC URL, you could do something like this to list them all:

<?php foreach (explode("\t", trim($guided_tourRecord['tour_location'])) as $countryCode): ?>
<img src="images/flag_<?php echo htmlspecialchars($countryCode) ?>.gif" />
<?php endforeach ?>


I hope this helps. Please let us know if you have any questions or comments.
All the best,
Chris

Re: [chris] Display if something is from a checkbox multi value list

By (Deleted User) - October 11, 2009

Chris, once again this is great and has reduced the amount of code in my page by about 15 lines...

As you have probably guessed by now I have been building a tour guide site. I am displaying flags with this method for the countries the tour travels through. However, I am running into a little bother when it comes to US states. It's obviously displaying a nice US flag for each state - is there a way to limit the amount of flags listed to 2?

I can supply a url link to you personally if you like??

Thanks Jono.

Re: [jonoc73] Display if something is from a checkbox multi value list

By Chris - October 11, 2009

Hi Jono,

Can you please post the PHP source code for the page in question?
All the best,
Chris