I'm rather new at PHP and having been trying to modify these two lines to work with four options instead of two
if ($this->db->VARS["allow_age"]==1) {
$AGE= ($this->age==20) ? " <img src=\"img/20.gif\" width=\"12\" height=\"12\">" : " <img src=\"img/30.gif\" width=\"12\" height=\"12\">";
}
if ($this->db->VARS["allow_age"]==1) {
$AGE = ($row['age']==20) ? " <img src=\"img/20.gif\" width=\"12\" height=\"12\">" : " <img src=\"img/30.gif\" width=\"12\" height=\"12\">";
}
I want this to display a different image if the variable is 20, 30, 40 or 50. and not just 20 and 30. I have tried everything I can think of. Any help. Thanks ahead of time
Adding more options to an If Statement
Moderator: General Moderators
-
microthick
- Forum Regular
- Posts: 543
- Joined: Wed Sep 24, 2003 2:15 pm
- Location: Vancouver, BC
How about using the switch statement, rather than if.
read up here for examples:
http://ca2.php.net/manual/en/control-st ... switch.php
read up here for examples:
http://ca2.php.net/manual/en/control-st ... switch.php