Display image with value

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Display image with value

Post by weblearner »

Hi all

Had setup a dynamic table query displaying all my fields correctly...
one of the fields is:
<td bgcolor="#CCCCCC"><?php echo $row_rsParts['PB']; ?></td>

the values of the column field 'PB' is either yes or no.
how do i make it display 'yes.gif' if the value is yes and 'spacer.gif' if the value is no.
Would appreciate if fellow friends could help me out and give me some pointers. Many thanks.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Display image with value

Post by requinix »

User avatar
phazorRise
Forum Contributor
Posts: 134
Joined: Mon Dec 27, 2010 7:58 am

Re: Display image with value

Post by phazorRise »

weblearner wrote:Hi all

Had setup a dynamic table query displaying all my fields correctly...
one of the fields is:
<td bgcolor="#CCCCCC"><?php echo $row_rsParts['PB']; ?></td>

the values of the column field 'PB' is either yes or no.
how do i make it display 'yes.gif' if the value is yes and 'spacer.gif' if the value is no.
Would appreciate if fellow friends could help me out and give me some pointers. Many thanks.

Code: Select all

<?php if($row_rsParts['PB']=='yes')  
$img='yes.gif';
Elseif ($row_rsParts['PB']=='no')
$img='spacer.gif'; ?>
<img src='<?php echo $img; ?>' >
weblearner
Forum Newbie
Posts: 20
Joined: Wed Dec 29, 2010 9:01 am

Re: Display image with value

Post by weblearner »

hey phazorRise

many thanks for helping, had followed your code and it works. :)
Post Reply