showing an image conditionally
Moderator: General Moderators
-
kristie380
- Forum Commoner
- Posts: 36
- Joined: Sun Oct 09, 2005 10:51 pm
showing an image conditionally
I am trying to get my script to show an image if a field has an entry and to not show the image if the field does not have an entry. How could I do this?
Code: Select all
$image = $results["Image"];
if (empty($image)) {
echo "";
}
else {
echo "<img src='image/image.gif' ></a><bR>";
}-
kristie380
- Forum Commoner
- Posts: 36
- Joined: Sun Oct 09, 2005 10:51 pm
Ok here is my code that I tried:
I want to show an image with a link to the person's email address if they entered an e-mail address. So the field name I am checking for a entry in is called "email". The code above did not work. Did I miss something?
Code: Select all
$email = $result["email"];
if (empty($email)) {
echo "";
}
else {
echo "<a href=\"mailto:$email\"><img src=\"images/mail.gif\" border=\"0\"></a> ";
}Code: Select all
$email = $result["email"];
if (empty($email)) {
echo "";
}
else {
echo "<a href=\"mailto:" . $email . "\"><img src=\"images/mail.gif\" border=\"0\"></a> ";
}what you want is this:
Code: Select all
$image = $results["Image"];
$email = $results["'Email"];
if (empty($image)) {
echo "";
}
else {
echo "<a href="mailto:$email?subject=Subject Line"><img src='image/image.gif' ></a><bR>";
}Code: Select all
if (!empty($image)) {
echo "<img src=" //etc
}Code: Select all
if (isset($_POST['image'])) {
echo "<img src=" //etc
}