View Full Version : [PHP Includes - Help] Linking.
Hitman
11-09-2006, 01:20 PM
Hey, I want to use PHP includes for the content on my site, but how would I go about this? I want it so when you press the link saying "Home" for example, I would click it and then in the content box it'd change to the homepage text.
If you didn't undertstand that, I want it so it's like an iframe, where you click the link and it gets the iframes info and puts it in the content section, jut with php includes.
It's sorta hard to explain xD
Thanks.
Dentafrice1
11-09-2006, 02:22 PM
Hmm.. like index.php?page=balkbjalkj?
JoeComins
11-09-2006, 02:37 PM
Put this code where you want your page to appear:
<?php
$val = $_GET['id'];
$val .= ".php";
$dirty = array("..");
$clean = array("");
$val = str_replace($dirty, $clean, $val);
if (isset($_GET['id'])) {
if (file_exists($val)) {
include "$val";
}
else {
include "404.php";
}
}
else {
include "home.php";
}
// Include this script in your content area
// Run ?id=pagename (without .php) to view a page
?>
That will show either your home.php or error page.
If not, make a home.php
Then your link to show any other pages would be:
http://www.DOMAIN.com/index.php?id=PAGE
Dont put teh .PHP on the end
Hitman
11-09-2006, 02:44 PM
I dunno if thats what I meant xD
I wanted it so that instead of clicking "news.php" on my site, then it going to a whole new page, I wanted it so when I clicked "news.php" it would open where the old content was. Like an iframe. But with php includes.
ClubTime
11-09-2006, 03:27 PM
http://techtuts.com
JoeComins
11-09-2006, 03:36 PM
Yes - That is right - Use it - I use that on every site.
if you put that code where you wnt your page to open. . . .
I dunno if thats what I meant xD
I wanted it so that instead of clicking "news.php" on my site, then it going to a whole new page, I wanted it so when I clicked "news.php" it would open where the old content was. Like an iframe. But with php includes.
I think you're looking for a JavaScript navigation method. (http://habboxforum.com/showpost.php?p=2134274&postcount=9)
Hitman
11-09-2006, 03:41 PM
Yes - That is right - Use it - I use that on every site.
if you put that code where you wnt your page to open. . . .
Okay thanks Joe.
And josh, it's ok now ;)
JoeComins
11-09-2006, 03:50 PM
Whats the site, and ill do it for you
Joshua - What the hell mate? Just no
Hitman
11-09-2006, 06:02 PM
Whats the site, and ill do it for you
Joshua - What the hell mate? Just no
Site is team-x-labs.net, PM me.
PM me ;) Or I may have done it by the time your online (doing now).
EDIT: I don't think it is what I mean. Cos, as far as I can tell (I may be wrong), but when you click the link in the nav, it opens the page, loads all the template again, then gets the file you want and puts it in the box where the code goes.
I want it so it loads the template once, then the rest is like iframes. So you click the link and the only thing it does is load the content. Isn't there a way so it says <? include ("file.php") id="name"?> then on the link you make it so it loads over name?
Dentafrice1
11-09-2006, 07:58 PM
What he wants is like an iframe.. it refreshes without refreshing the page.. but he needs it with PHP includes
JoeComins
11-09-2006, 08:01 PM
Well thats a PHP Include. You are not going to be able to do it any other wa, or atleast not as effective
Dentafrice1
11-09-2006, 08:03 PM
Javascript.. but he needs it not to refresh like the whole page.. maybe he has a radio on there.. that would refresh the radio?
Mentor
11-09-2006, 08:09 PM
why not just use an iframe?
JoeComins
11-09-2006, 09:19 PM
It seems that he wants to use an iFrame, but wont.
PHP Includes are far better than iFrames.
And Carl, can you jsut say if Ive explained that well enough?
I know thats what I use anyway
Mentor
11-09-2006, 09:44 PM
php includes requre page reloading, if you dont want that ifraims the way to go, kinda why there there? nether is better. Each is just better for diffent things. In this case a ifraime would probably be the better choise, but often php include navs are better since people can direct link to page content etc?
Hitman
12-09-2006, 06:53 AM
Hey guys,
I don't have a radio or anything, its just so the page doesnt take time to reload for people on a slow internet connection.
The reason I don't want to use an iframe is because they don't expand.
Thanks for all your help anyway guys. ;)
Motion
12-09-2006, 06:58 AM
iframes r gay.
hi tom
Xuzuno (Forum Moderator) - Please don't post off topic.
Do you mean when you click something like home it don't reaload it just shows the home stuff text etc, when u click videos it would show videos instead of reloading the same layout?
Motion
12-09-2006, 05:51 PM
No he wants PHP Includes........... As in ?page=stuff or ?page=videos etc i know how to do it he never listens to me though like im not good enough ;[
Hitman
12-09-2006, 05:52 PM
Do you mean when you click something like home it don't reaload it just shows the home stuff text etc, when u click videos it would show videos instead of reloading the same layout?
Yes like an iframe when it has target="main", so the iframe called main would be replaced with the text. :)
Motion
12-09-2006, 05:53 PM
Tom you cant do it like that i will help if you get yo white asss on msn
Hitman
12-09-2006, 06:02 PM
No he wants PHP Includes........... As in ?page=stuff or ?page=videos etc i know how to do it he never listens to me though like im not good enough ;[
Look, I want it so it's like an iframe. You know when you click an iframe link, it replaces the old content with the other pages content, like that, but using php includes, or something that will expand.
Ryan, the ?page=stuff isn't what I want, unless thats how its done, but I don't see how it helps.
Motion
12-09-2006, 06:16 PM
FGS TOM FOR THE LAST TIME WHEN YOU USE PHP INCLUDES IT IS LIKE PAGE=BLABLABLA I HAVE SAID ON MSN 50000000000 TIMES.
PHP cannot be used to create an effect similar to an IFrame, it's a server-side language, it cannot modify the page once the page has loaded. You'll need to use JavaScript, frames or an IFrame to change the content without having to reload the page.
Dentafrice1
12-09-2006, 08:50 PM
Again.. Javascript :p What I told you two pages ago :p
Hitman
12-09-2006, 09:12 PM
FGS TOM FOR THE LAST TIME WHEN YOU USE PHP INCLUDES IT IS LIKE PAGE=BLABLABLA I HAVE SAID ON MSN 50000000000 TIMES.
You've never said about page=blahblah before.
PHP cannot be used to create an effect similar to an IFrame, it's a server-side language, it cannot modify the page once the page has loaded. You'll need to use JavaScript, frames or an IFrame to change the content without having to reload the page.
Okay, thanks.
Again.. Javascript :p What I told you two pages ago :p
What if people disable javascript =[
Is there any Iframes that expand?
RyanS
12-09-2006, 09:15 PM
Tom, IFrame stands from Inline Frame its a page opened in the same window, but like another window in that page, they do not expand.
Hitman
13-09-2006, 08:44 AM
Tom, IFrame stands from Inline Frame its a page opened in the same window, but like another window in that page, they do not expand.
I'm not stupid Ryan. :S
I'm just saying, there might be something like that.
:Blob
13-09-2006, 05:04 PM
AJAX.
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-articles/ajax-dynamic-articles.html
http://www.dhtmlgoodies.com/index.html?page=ajax
Scroll to bottom
Hitman
13-09-2006, 05:53 PM
AJAX.
http://www.dhtmlgoodies.com/scripts/ajax-dynamic-articles/ajax-dynamic-articles.html
http://www.dhtmlgoodies.com/index.html?page=ajax
Scroll to bottom
Thank you very much, this may be it. :)
Mentor
13-09-2006, 09:17 PM
iframes do exsplain, check out the search on thybag theres an exsample, it uses a little js though. plus i think i fecked it up for ie recently and havent yet fixed
Want to hide these adverts? Register an account for free!
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.