Hello....
I can use php to determine if a url variable exists and echo something to the screen based upon it:
<?php
if ($_GET["ID"] != '')
{ echo "there is no ID";
}
else {
echo "yes there is";
}
?>
but I can't figure a bowlegs and curly braces syntax that allows me to do further php stuff based on that knowledge. I would like, for example, to include a specific hyperlink or image based on the URL variable. These work on their own:
<?php print '<a href="printer_friendly.mvc?ID=' . $_GET["ID"] . '">' ;?>printer friendly</a>
<?php print '<IMG SRC="images/' . $_GET["ID"] . '.gif" >';?>
How can I stuff that sort of thing inside the conditional statement, so that the image or link only appears if the url variable exists?
Thanks
rg
A newbie question re php varibles inside an IF
Moderator: General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
<?php
if (!empty($_GET['ID']) && is_numeric($_GET['ID']))
{
print '<a href="printer_friendly.mvc?ID=' . $_GET['ID'] . '">printer friendly</a>';
print '<IMG SRC="images/' . $_GET['ID'] . '.gif" >';
}
?>