fri3ndly Posted May 9, 2007 Share Posted May 9, 2007 Please can someone help me out here: I am trying to make an IF statement that is something like this, you will get the general idea what I am trying to do but I really have not got my head round IF statements. Please help, thank you <?php if (page="?page=about.txt") "<img src="images/aboutbar.jpg" width="800" height="141" />" ; } if (page="?page=services.txt") "<img src="images/servicesbar.jpg" width="800" height="141" />" ; } else{ <img src="images/homebar.jpg" width="800" height="141" /> ?> Quote Link to comment Share on other sites More sharing options...
only one Posted May 9, 2007 Share Posted May 9, 2007 if($_GET ==about.txt){ instead of if (page="?page=about.txt") and so on.. Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 Ah thanks! So, if I want to do like 5 or 6 IF statements, do i Just keep doing 'IF','IF','IF' and then an 'else' at the end? Quote Link to comment Share on other sites More sharing options...
jitesh Posted May 9, 2007 Share Posted May 9, 2007 http://php.net/if Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks :-) Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 Ok, so this is my script now, but I keep receiving errors. Obviously I cannot echo an image to show up, so that is obviously wrong, anything else anyone notices? I think the script is not liking the html, do I need to end the php tags and restart them for each part of html? if($_GET ==about.txt){ echo "<img src="images/topleftbartest.jpg" width="800" height="141"/>"; }elseif{ echo "<img src="images/topleftbartest2.jpg" width="800" height="141"/>"; }else{ echo "<img src="images/topleftbartest2.jpg" width="800" height="141"/>"; } ?> Quote Link to comment Share on other sites More sharing options...
taith Posted May 9, 2007 Share Posted May 9, 2007 switch($_GET ){ case "about.txt": echo '<img src="images/topleftbartest.jpg" width="800" height="141"/>'; break; case "": echo '<img src="images/topleftbartest2.jpg" width="800" height="141"/>'; break; default: echo '<img src="images/topleftbartest2.jpg" width="800" height="141"/>'; break; } Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 thank you very much. That makes sense and the default image shows up, but the selected images do not. <?php switch($_GET ){ case "index2.php?page=about.txt": echo '<img src="images/topleftbar1.jpg" width="800" height="141"/>'; break; case "index2.php?page=services.txt": echo '<img src="images/topleftbar2.jpg" width="800" height="141"/>'; break; default: echo '<img src="images/topleftbar.jpg" width="800" height="141"/>'; break; } ?> I have tried changing the page names, but that is what the page name changes to in the top of the browser Quote Link to comment Share on other sites More sharing options...
taith Posted May 9, 2007 Share Posted May 9, 2007 case "index2.php?page=services.txt": case "services.txt": Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 It does not appear to work with just 'about.txt'. this php code is in a file called header.php, and the text files load up in 'index2.php' That would'nt matter would it? Quote Link to comment Share on other sites More sharing options...
taith Posted May 9, 2007 Share Posted May 9, 2007 nope! as long as your url has "?page=about.txt" on it... it should work... Quote Link to comment Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 AH GOT IT, it works without '.txt' at all MANY THANKS!!!! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.