rileyrichter Posted April 13, 2009 Share Posted April 13, 2009 Hey guys - I need help. I am new to PHP - I just started. I templated a site in PHP and so far so good. I am basically calling a template which is including a menu, sidebar, and content, etc. With each topic they wanted a different header image, so I actually created different template pages for each category. I was wondering how I could do the following with php ----------------------- if page1 is loaded then echo image1.jpg if page2 is loaded then echo image2.jpg and so on . . . else default.jpg --------------------------- Any help would be GREATLY appreciated. Link to comment https://forums.phpfreaks.com/topic/153932-need-help-with-php-header-images/ Share on other sites More sharing options...
mrMarcus Posted April 13, 2009 Share Posted April 13, 2009 using the $_GET method, attach ?page=page_number_here where 'page_number_here' is (whatever you make it) the number of the page. must match the case name below in the switch() statement, ie. www.yoursite.com/index?page=one .. your case name must match what's in the url, otherwise, default: is displayed. <?PHP if (isset ($_GET['page'])) { $page = trim($_GET['page']); switch ($page) { case one: echo '<img src="image_one.jpg" />'; break; case two: echo '<img src="image_two.jpg" />'; break; default: echo '<img src="default_image.jpg" />'; break; } } ?> Link to comment https://forums.phpfreaks.com/topic/153932-need-help-with-php-header-images/#findComment-809008 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.