deed02392 Posted October 18, 2007 Share Posted October 18, 2007 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 Quote Link to comment https://forums.phpfreaks.com/topic/73878-if-page-about-show-the-abouthtml-page/ Share on other sites More sharing options...
kenrbnsn Posted October 18, 2007 Share Posted October 18, 2007 Use $_GET['page'], not $page <?php if ($_GET['page'] == 'about') { ?> <iframe src="about.html" name="About" width="20" height="20"> Your browser does not support Iframes! Update now. </iframe> <?php } ?> Ken Quote Link to comment https://forums.phpfreaks.com/topic/73878-if-page-about-show-the-abouthtml-page/#findComment-372789 Share on other sites More sharing options...
deed02392 Posted October 19, 2007 Author Share Posted October 19, 2007 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 :/ Quote Link to comment https://forums.phpfreaks.com/topic/73878-if-page-about-show-the-abouthtml-page/#findComment-373091 Share on other sites More sharing options...
steve448 Posted October 19, 2007 Share Posted October 19, 2007 Try changing: elseif ($_GET['page'] == 'index' || 'home') To: elseif (($_GET['page'] == 'index') || ($_GET['page'] == 'home')) Quote Link to comment https://forums.phpfreaks.com/topic/73878-if-page-about-show-the-abouthtml-page/#findComment-373095 Share on other sites More sharing options...
deed02392 Posted October 19, 2007 Author Share Posted October 19, 2007 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! Quote Link to comment https://forums.phpfreaks.com/topic/73878-if-page-about-show-the-abouthtml-page/#findComment-373197 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.