Hi,
I have a simple request I think.
I know how to formulate it in asp, but need help in php.
I need to have an example of code for the following:
(I write it as I mean it)
IF {rsMP3.Price}="FREE" THEN SHOW <a href="<?php echo $row_rsMP3['downloadurl']; ?>">Download free track</a>
Basically, if my recordet value for the field MP3.Price is the word FREE then a download link should show as shown above.
could you help me with that?
Thanks,
Vinny
IF condition
Moderator: General Moderators
hmmm...
Code: Select all
<?php // IF condition starts
if ($row_rsMP3['price']=="FREE") { // Checks for the Free value of the Price field
?>
<a href="<?php echo $row_rsMP3['downloadurl']; ?>"> Download Free Track</a>
<?php } // IF condition Ends ?>You could also do this for the same result:
Code: Select all
<?php
if ($row_rsMP3['price'] == "FREE") {
echo "<a href='{$row_rsMP3['downloadurl']}'> Download Free Track</a>";
} // IF condition Ends
?>or
Code: Select all
echo ($row_rsMP3['price'] == "FREE" ? "<a href='{$row_rsMP3['downloadurl']}'>Download Free Track</a>" : "");PHP is lovely isn't it? You can also do:
-Nay
Code: Select all
<?php
if ($row_rsMP3['price'] == "FREE") {
echo <<< LINK
<a href="{$row_rsMP3['downloadurl']}">Download Free Track</a>
LINK;
}
?>