hi.. i need help with this code

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guysoul
Forum Newbie
Posts: 4
Joined: Mon Mar 19, 2012 6:31 am

hi.. i need help with this code

Post by guysoul »

Hello,

I created a dynamic body ID. and this is my script

Code: Select all

if($page == "index.php")	{ 	echo '<body id="page1">'; }
	else if($page == "om.php") { echo '<body id="page2">'; }
For some reason its not working. When i go to index.php, the menu HOME is highlighted but when i go to om.php, the menu HOME is still highlighted.. It should highlight OM menu.

When i view the sourcecode on index.php, i saw two body tags:

<body id="page1">
<body id="page1">

When I view the sourcode on om.php. i saw this:
<body id="page2">
<body id="page1">

I dont understand why is this happening. it should only display one body tag. And each page, i declared the pages as:

For index.php , its $page = "index.php";
For om.php, its $page = "om.php";

Hope to hear from you soon.

Thanks and have a great day!

Regards,
Ed
guysoul
Forum Newbie
Posts: 4
Joined: Mon Mar 19, 2012 6:31 am

Re: hi.. i need help with this code

Post by guysoul »

can anyone help me???
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: hi.. i need help with this code

Post by Celauran »

guysoul wrote:can anyone help me???
Not with the information provided, no. Post more code so we can see what's causing the duplicated <body> tags.
guysoul
Forum Newbie
Posts: 4
Joined: Mon Mar 19, 2012 6:31 am

Re: hi.. i need help with this code

Post by guysoul »

thanks for your response..

the code

Code: Select all

if($page == 'index.php')	
{ 	
	echo '<body id="page1">'; 
}
elseif($page == 'om.php')
{
	echo '<body id="page2">'; 
}
is written on the Template file.

On index.php and om.php, i declared a variable $page.

i hope this helps
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: hi.. i need help with this code

Post by Celauran »

It doesn't help at all. That's what you posted in the first post. This explains the second body tag, but not the first.
guysoul
Forum Newbie
Posts: 4
Joined: Mon Mar 19, 2012 6:31 am

Re: hi.. i need help with this code

Post by guysoul »

hi celauran,

I get it now. why it displayed two body tags.. :) my real concern is to create a PHP script that will automatically change the body id tag on each page since body tag is within the templates.

can u help me with my script above? i dont understand why it gives me an error.. thanks
Post Reply