Displaying image depending on column data

I’ve been asked to create a simple index at work that will display contents of our database.

What i need to do is display an image depending on a field in the database.

The thing is, i can’t use echo or print to display the image depending on the field because we’re using a templating system. I can get the list to display the word green for yes and red for no but what i really need it do do is display an image. Could you guys please help me out?


Here is the code i have so far…

(PHP File)
$reflist = array(); $x = 0;
$refer_count = db_query(“SELECT *, DATE_FORMAT(release_date, ‘%e-%b-%Y’) AS release_date FROM data_portal.P_products WHERE release_date<=DATE_ADD(CURDATE(),INTERVAL 30 DAY) AND release_date>=CURDATE()”);
if ($refer_count->numRows()) {
while ($row = $refer_count->fetchRow()) {
$rc = ($rc == ‘odd’ ? ‘even’ : ‘odd’);
$name = $row[‘R_name’];
$id = $row[‘id’] + 0;
$url ="/game.php?id=$id";

//This needs to display an image depending on what this value is
$confirmed = $row['release_confirmed'];
	if ($confirmed  = 'yes') {
		$confirmed_image = 'green';
	} else { $confirmed_image = 'red'; }

$outwhen = $row['release_date'];

//This is not the correct way to format the data, it is better for everyone if we 
//format it, when we run the query.
//$outwhen_fixed = date('d-m-Y', strtotime($outwhen)); 

$x ++;
    'releases.dates' => $x,
    'releases.rc' => $rc,
	'releases.headline' => trim($name),
	'releases.icon' => $icon,
	'releases.confirmed' => trim($confirmed_image),
	'releases.outwhen' => trim($outwhen),
	'releases.url' => trim($url),     
  	'releases.format' => make_format_icon($row['R_format']),


} else {


(html template file)

<table cellspacing="0" cellpadding="0" border="0" width="600">
			  <!-- BEGIN releases -->
			<div align="centre">	
			<tr><td width="150" align="left" class="list_{releases.rc}"><b><a href="{releases.url}">{releases.headline} {releases.format}</a></b></td><td class="list_{releases.rc}" width="100" align="centre" style="padding-left:20px;">Publisher</td><td width="100" align="centre" class="list_{releases.rc}"><b>{releases.outwhen}</b></td><td width="10" align="centre" class="list_{releases.rc}">{releases.confirmed}</td></tr></div>
	<!-- END releases -->

are u talking about the icon?

have u tryed this? <img src="path/to/the/icons/{releases.icon}" />

Sponsor our Newsletter | Privacy Policy | Terms of Service