Hi...
Fairly new to PHP and trying to work with some images...
I have a page where I need to display a different header image on based on a business type that is coming from MySQL... There are seven total options... is there an easy if statement that can handle this in PHP?
Since I can see no code something like the switch method:
[php]
$business_type=... whatever comes from the database
switch ($business_type) {
case 'a' : $img = 'type1.png';
break;
case 'b' : $img = 'type2.png';
break;
............................
............................
case 'g' : $img = 'type7.png';
break;
default : $img = 'noimage.png';
break;
}
echo "<img src='$img' border='0' />"
--- etc.
[/php]
Another method is to store it in an associative array and get the image name from there:
[php]
$array=array('a'=>'type1.jpg', 'b'=>'type2.jpg', ......... 'g'=>'type7.jpg');
if (isset($array[$business_type]))
$img=$array[$business_type];
else
$img='noimage.png';
echo "<img src='$img' border='0' />"
..... etc ....
[/php]
Ronald