Jump to content

Recommended Posts

Ok here is what im doing. Im trying to add a background image using php in css but im not sure if I have it set up right.

 

http://www.alabamastormtrackers.com/metar/conditions.php

See where it says (Sky: Heavy Rain)

I need a graphic to display IF Heavy Rain is present.

 

Trying to explain this best I can..

 

This is part of the CSS outside of the PHP script.

background: #cccccc url(<?php echo $image; ?>);

 

 

Here is the IF statement im not sure if I set up right.

 

if ($wxInfo['CONDITIONS'] == Heavy Rain) {

$image = "http://www.alabamastormtrackers.com/metar/Rain_Heavy.png";

}

 

 

 

Here is the whole script:

http://www.alabamastormtrackers.com/metar/script.txt

If you run the script your self to test you will also need this:

http://www.alabamastormtrackers.com/metar/conditions_metars.txt

 

Here is an EXAMPLE of what it should look like

http://www.alabamastormtrackers.com/metar/example.php

 

 

I have no idea what im missing?????

THANKS :)

Link to comment
https://forums.phpfreaks.com/topic/177624-quick-question-for-you-guys/
Share on other sites

Well, either way you needed the quotes around the string...

 

You should check to see that you have error reporting turned on... when I ran the script I got a parse error where the quotes were missing.

 

error reporting is on i was just playing with the script.

I wonder if it could be because the entire output is not generated by php?

Ok i played around some more and maybe have found a different way...

At the bottom of the script I have added

 

 

if ($observed == "Overcast") {
$icon = "http://www.alabamastormtrackers.com/metar/Rain_Heavy.png";
}
echo "<img src=" . "$icon" . ">";
?>

 

Now the image does display but just in a different location. Is there a way to position the image at the top right portion of the box?

http://www.alabamastormtrackers.com/metar/conditions.php

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.