I'm very new to php / MySQL, so please excuse the ignorance.. hehe...
I'm having a problem that I'm sure is easy to figure out, but I've looked through php.net and still cannot figure out how to resolve this. Basically, I have a page on my site that will display trucks and truck info. If the owner submitted an email address, I want the page to also display an email link so people can contact him/her.
Here's the code that I'm using, but it doesn't work.
<?php
if ($email ne "")
{
echo "- <href="mailto:$email">[contact owner]</a>";
}
?>
Below is the code for the entire page. I'm not sure if that helps. I just had a feeling that the problem is there because of something else on the page.
Any help at all is really appreciated.
<?
include("../dbinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM truck";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
echo " ";
?>
<html>
<title>Abused Trucks!</title>
<meta name="keywords" content="">
<meta name="description" content="">
<?php include "../header.php";?>
<td width="145" valign="top">
<?php include "menu.php";?>
</td>
<td width="675">
<table border="0" width="100%">
<tr>
<td width="15" class="body" background="/images/bg_vert.gif" valign="top" rowspan="8">
</td>
<td class="body" colspan="2" width="650" align="center">
<table border="0" width="100%" cellpadding="5" cellspacing="0">
<?
$i=0;
while ($i < $num) {
$id=mysql_result($result,$i,"id");
$status=mysql_result($result,$i,"status");
$year=mysql_result($result,$i,"year");
$make=mysql_result($result,$i,"make");
$model=mysql_result($result,$i,"model");
$truckname=mysql_result($result,$i,"truckname");
$owner=mysql_result($result,$i,"owner");
$email=mysql_result($result,$i,"email");
$location=mysql_result($result,$i,"location");
$website=mysql_result($result,$i,"website");
$summary=mysql_result($result,$i,"summary");
$image=mysql_result($result,$i,"image");
?>
<tr>
<td class="body" background="/images/dot.gif" height="3" colspan="2"> </td>
</tr>
<tr>
<td bgcolor="black" class="body">
<b><?php echo "$year"?> <?php echo "$make"?> <?php echo "$model"?></b>
</td>
<td bgcolor="black" class="body" align="right">
<b><?php echo "$location"?></b>
</td>
</tr>
<tr>
<td valign="top">
<img src="/images/trucks/<?php echo "$image"?>" width="200">
</td>
<td class="body" valign="top">
<table border="0">
<tr>
<td class="body"><b>Truck Name:</b></td>
<td class="body"><?php echo "$truckname"?></td>
</tr>
<tr>
<td class="body" background="/images/dot.gif" height="3" colspan="2"> </td>
</tr>
<tr>
<td class="body"><b>Owner Name:</b></td>
<td class="body"><?php echo "$owner"?>
<?php
if ($email ne "")
{
echo "- <href="mailto:$email">[contact owner]</a>";
}
?>
</td>
</tr>
<tr>
<td class="body" background="/images/dot.gif" height="3" colspan="2"> </td>
</tr>
<tr>
<td class="body"><b>Truck Body:</b></td>
<td class="body"><?php echo "$year"?> <?php echo "$make"?> <?php echo "$model"?></td>
</tr>
<tr>
<td class="body" background="/images/dot.gif" height="3" colspan="2"> </td>
</tr>
<tr>
<td class="body"><b>Web Site:</b></td>
<td class="body"><a target="_blank" class="body" href="http://www.<?php echo "$website"?>">[url]http://www.[/url]<?php echo "$website"?></a></td>
</tr>
<tr>
<td class="body" background="/images/dot.gif" height="3" colspan="2"> </td>
</tr>
<tr>
<td class="body" valign="top"><b>Additional Information:</b></td>
<td class="body"><?php echo "$summary"?>
</td>
</tr>
</table>
</td>
</tr>
<?
++$i;
}
echo " ";
?>
<?php include "../footer.php";?>