Jump to content

Need help with php - header images


rileyrichter

Recommended Posts

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

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;
}
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.