A newbie question re php varibles inside an IF
Posted: Sun Jul 02, 2006 10:43 am
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
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