Hi I am newbie so apologies for my ignorance! I am creating a business directory database that stores shops address details phone number etc. I’m currently using the following query to pull back the data from the database and display it in the PHP. I was wondering if someone could help me with the code needed to only pull back present data, for example I specify ‘Fax: $shop_fax’ so if there is a fax number it displays something like ‘Fax: 01458 12345’ but if a fax number isn’t stored im left with ‘Fax:’ and a blank space. What I need is a nifty bit of code that will only display the title if data exists, I’m sure it’s a simple thing to do, anyone know what I need? I would really appreciate the help; my e-mail address is chris@forscutt.com (cc to) cforscutt@hotmail.com
<?
if ($id) {
$result = mysql_query("SELECT * FROM $table WHERE id=$id",$db);
$links = mysql_fetch_array($result);
$id = $links["id"];
$shop_name = $links["shop_name"];
$shop_image = $links["shop_image"];
$shop_short_descr = $links["shop_short_descr"];
$shop_long_descr = $links["shop_long_descr"];
$shop_telephone = $links["shop_telephone"];
$shop_fax = $links["shop_fax"];
echo "<b>$shop_name</b><br><br>";
echo "<table width=525 border=0 cellspacing=0 cellpadding=0>
<tr>
<td width=65% valign=top>$shop_long_descr<br><br>
Tel: $shop_telephone<br>
Fax: $shop_fax
</td>
<td width=200 valign=top align=right><img src=images/shops/$shop_image alt=shopfront hspace=10></td>
</tr>
</table>";
} else {
echo "You need to select a Shop ID";
}
?>
|