djzman
-
Posts
7 -
Joined
-
Last visited
Posts posted by djzman
-
-
how do i make this so i can click on the alertbox gif
Thanks all.
<?phpif (file_exists('number.txt')){$fil = fopen('number.txt', r);$dat = fread($fil, filesize('number.txt'));echo "<img src='alertbox{$dat}.gif'>";fclose($fil);}?> -
Thank you everyone for helping me get this code right.
I know sometimes when you help people you never get to see what they are doing.
I run Wisconsin Storm Chasers and we have a alert (red yellow green) flashing light on our main website.and i cant be around the computer all the time to log in to change it from one color to another when weather changes.
so now the members of the club who have the link can do it. so it gets changed faster to warn the public.
here is a test page i was working on, you can see it working now. http://wisconsinstormchasers.com/testing123
and if you go to our main website you can see where the light is on the page http://wisconsinstormchasers.com/home
Thank you again for all the help. -
Also, you have some extra parenthesis after the echo statements.
For what it's worth, you could simplify the code by using file_get_contents(). You also don't need the separate if tests for $dat. You could try something like this:
<?php if (file_exists('number.txt')) { $fil = fopen('number.txt', r); $dat = fread($fil, filesize('number.txt')); echo '<img src="image' . $dat . '.png"'; fclose($fil); } ?>
Of course, you should check that the image file exists before trying to display it.
I got this one now to work thanks to CyberRobot
I changed this: echo '<img src="image' . $dat . '.png"';
to this: echo "<img src='image{$dat}.png' />";
and now that code is working.
So thanks everyone.
-
@CyberRobot
This is working see for your self, www.wisconsinstormchasers.com/testing123Thank you.
-
Thanks Guru but its not loading the image. I do have image1.png image2.png and image3.png
www.wisconsinstormchasers.com/testing123/image1.pngwww.wisconsinstormchasers.com/testing123/image2.png
www.wisconsinstormchasers.com/testing123/image3.png
and number.txt is set to 1
www.wisconsinstormchasers.com/testing123/number.txt
and the index.php has your code in it. I did make arue to make number.txt Read Write and executable (incase it needed to be)
so something is still wrong that its not loading.
-
Im stuck. would someone please help me. I can get it to echo the number but not a image.----------------------<?phpif (file_exists('number.txt')){$fil = fopen('number.txt', r);$dat = fread($fil, filesize('number.txt'));if ($dat = 1) echo '<img src="image1.png"');if ($dat = 2) echo '<img src="image2.png"');if ($dat = 3) echo '<img src="image3.png"');fclose($fil); }?>--------------------------the number.text is in the same dir. the image's are in the same dirand the php code is in the same dir.and the number.txt i set to 777 (just incase it needed to be)thanks for any help. (I hope i wrote this in the right form if not sorry)
im stuck with my code. IF this = that show image code.
in PHP Coding Help
Posted
Yes sir i did. Oh and I did fig it out last night after looking over the image code.
Since i seen they used ' instead of " i tryed echo "<a href='http://alerts.weather.gov/cap/wi.php?x=1' target='_large'><img src='image{$dat}.png'></a>";
And that worked. what i was doing wrong before im use to in php and html using the " instead of the ' and thats what did me wrong.
But I do thank you for those links. W3 i use that website a lot, but when i get stuck i come here.
Thank again.