Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP Newbie Alert!

Status
Not open for further replies.

PinkMink

Technical User
Mar 28, 2005
7
US
Good evening guys and gals, I am in the process of creating a Record Shop website using a combination of php connecting to a MySql database (hosted by Lycos).

I have a field within my database that contains a link to a mp3 sample of the track for that particular row. It's taking me a while to update the mp3's onto the website and with this in mind, I only want the website to display a link to this sample 'if' one actually exists.

I have managed to piece together this bit of code which displays the button regardless of whether there is a mp3 detailed or not...


<td><a href = "<?php echo $row_test['sample']; ?>"><img src=" border="0"></a></td>


...but I was wondering if I can insert an 'if' statement somewhere in the code that will display another image if the 'sample' field is null?

Thanks for your time.

Regard, Rob
 
one option is:
<td>
<? if($row_test['sample']!= 'NULL')
{
?>
<a href = "<?php echo $row_test['sample']; ?>"><img src=" border="0"></a>
<?
}else{
?>
<a href = "<?php echo "NO image"; ?>"><img src="different image link" border="0"></a>
<?
}
?>
</td>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top