I have an HTML table that displays data from my database.
One of the columns in the HTML table is called 'Image', where I have the url of an image appearing.
Instead of having the url show, I want to just have an icon show up in that block that will link to the image location. But if there is no data for that column, I want the HTML table to display an empty block.
Here is the section of the code for the HTML table:
Line in question is the last line in the table.
<table border="2" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">ID</font></th>
<th><font face="Arial, Helvetica, sans-serif">MACID</font></th>
<th><font face="Arial, Helvetica, sans-serif">Name</font></th>
<th><font face="Arial, Helvetica, sans-serif">Date</font></th>
<th><font face="Arial, Helvetica, sans-serif">Type</font></th>
<th><font face="Arial, Helvetica, sans-serif">Departure</font></th>
<th><font face="Arial, Helvetica, sans-serif">Destination</font></th>
<th><font face="Arial, Helvetica, sans-serif">Time</font></th>
<th><font face="Arial, Helvetica, sans-serif">Charter #</font></th>
<th><font face="Arial, Helvetica, sans-serif">Charter Pay</font></th>
<th><font face="Arial, Helvetica, sans-serif">Comment</font></th>
<th><font face="Arial, Helvetica, sans-serif">Image</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$macid=mysql_result($result,$i,"macid");
$date=mysql_result($result,$i,"date");
$name=mysql_result($result,$i,"name");
$type=mysql_result($result,$i,"type");
$departure=mysql_result($result,$i,"departure");
$destination=mysql_result($result,$i,"destination");
$hours=mysql_result($result,$i,"hours");
$charterno=mysql_result($result,$i,"charterno");
$charterdoll=mysql_result($result,$i,"charterdoll");
$comment=mysql_result($result,$i,"comment");
$image=mysql_result($result,$i,"image");
$datePosted = "$date";
$formatted = date("M-d-Y", strtotime($datePosted));
$departure = strtoupper($departure);
$destination = strtoupper($destination);
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$id"; ?></a></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$macid"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$name"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$date) { echo " "; } else { echo $formatted; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$type) { echo " "; } else { echo $type; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$departure) { echo " "; } else { echo $departure; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$destination) { echo " "; } else { echo $destination; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo "$hours"; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$charterno) { echo " "; } else { echo $charterno; }?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$charterdoll) { echo " "; } else { echo $charterdoll; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$comment) { echo " "; } else { echo $comment; } ?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? if (!$image) { echo " "; } else ?><a href="<?{ echo $image; } ?>"><? echo "$image";?></a></font></td>
</tr>
<?
++$i;
}
echo "</table>";
?>
Any ideas how to go about this?