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" /> ?> Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/ 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.. Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248847 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? Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248848 Share on other sites More sharing options...
jitesh Posted May 9, 2007 Share Posted May 9, 2007 http://php.net/if Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248850 Share on other sites More sharing options...
fri3ndly Posted May 9, 2007 Author Share Posted May 9, 2007 Thanks :-) Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248853 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"/>"; } ?> Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248855 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; } Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248873 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 Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248882 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": Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248883 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? Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248884 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... Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248885 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!!!! Link to comment https://forums.phpfreaks.com/topic/50625-solved-very-quick-and-easy-for-php-intermediate/#findComment-248887 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.