Jump to content

if page = 'about' show the about.html page?


deed02392

Recommended Posts

Hi all, I wanted to do some kind of PHP script so that if the current page the viewer is trying to view is called index.php?page=about then it will use the php script to embed with an i-frame the about.html file into a cell in my web page's table. Basically, so that the whole page stays the same other than one cell of the table which is dynamic depending on the status of the index.php?page=whatever.

 

So far I've come up with:

 

<?php
if ($page == 'about')
	{ 
	?>
	<iframe src="about.html" name="About" width="20" height="20">
Your browser does not support Iframes! Update now.
</iframe>
	<? }

?>

 

But this doesn't seem to work at all when I visit localhost/index.php?page=about. instead just a blank area where it should be... I have included page= $_GET['page'] but i'm a complete noob at this, so little help :D

Link to comment
Share on other sites

Thanks, even though I had set the $page variable to $_GET['page'] etc it didn't work until I used your code. =)

One other thing I just need a quit bit of help with:

 

<?php
if ($_GET['page'] == 'about')
	{ 
	?>
	<iframe src="about.html" name="About" width="609" height="500" frameborder="0">
Your browser does not support Iframes! Update now.</iframe>
	<?php } 
elseif ($_GET['page'] == 'index' || 'home')
	{
	?>
	<iframe src="home.html" name="Home" width="609" height="500" frameborder="0">
Your browser does not support Iframes! Update now.</iframe>
	<?php }
elseif ($_GET['page'] == 'register')
	{
	?>
	<iframe src="register.html" name="Register" width="609" height="500" frameborder="0">
Your browser does not support Iframes! Update now.</iframe>
	<?php } ?>

 

What i'm trying to do is if the page == index.php?page=whatever then the iframe contating that page is integrated. It won't work beyond the first else if though. I've tried a few google searches but everyone seems to think that you can use multiple elseifs like this? I'm not sure waht the difference is though as I have HTML inbetween. What should I change? I need a couple more other than this yet to add :/

Link to comment
Share on other sites

Thanks! That worked wonders for everything, but it did make one problem.

 

If you visit the page without the index.php?page=home then the cell is blank and it doesn't display anything, so I just changed 'index' to '' and it loaded the iframe when viewing index.php

 

My website is really coming along now, thanks so much everyone!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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