Re: Create variables with IF staements
| From: | Ignacio Vazquez-Abrams | Date: | Wed, 13 Dec 2000 00:38:33 +0000 |
| Subject: | Re: Create variables with IF staements | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-29994@lists.php.net to get a copy of this message | ||
On Tue, 12 Dec 2000, David Smith wrote:
> I am trying to assign a variable from the result of an IF statement. How an
> I do this in php? I have a field called FileImageURL which houses nopic.jpg
> if no picture is there and if there is a picture it returns apicture.jpg. I
> want it to display an image called jpg.gif if there is a picture and
> blank.gif if there isn't. I want to insert the result as a variable in my
> tables as $Image. Any suggestions?
>
> David Smith
>
> ///////
>
> $Image = result of below...
>
> ///////
>
> if($FileImageURL=="nopic.jpg")
> {
> echo "<IMG SRC=\"/home/warbirds/images/blank.gif\"
> BORDER=\"0\">";
> }
> else
> {
> echo "<IMG SRC=\"/home/warbirds/images/jpg.gif\"
> BORDER=\"0\">";
> }
> endif
>
Try:
$imageArray=Array(
"nopic.jpg" => "/home/warbirds/images/blank.gif",
"apicture.jpg" => "/home/warbirds/images/jpg.gif"
);
$Image="<img src=\"{$imageArray[$FileImageURL]}\"
border=\"0\">";
Or:
$imageArray=Array(
"nopic.jpg" => "blank.gif",
"apicture.jpg" => "jpg.gif"
);
$Image="<img src=\"/home/warbirds/images/{$imageArray[$FileImageURL]}\"
border=\"0\">";
--
Ignacio Vazquez-Abrams <ignacio@openservices.net>