View Full Version : Dynamic Pages
Wz886
07-31-2005, 07:25 AM
Hello everyone I am pretty new to PHP. I am building a website and I don't want the whole page to reload everytime the user clicks a link but I really don't want to use iframes. Does anyone know a way I could get this done using PHP??
Thanks in advance.
Pennimus
07-31-2005, 03:15 PM
Yep, build the different parts of your pages as php includes.
The include code looks like this -
<?php include_once('includes/navigation.php');?>
This simple line of code replaces whatever block of html content you want to be located in a different file. The red text is the location of your include on your server. Then the browser need only load that block of content once, rather than every time the page changes.
I find the best way to go about this is to build your homepage normally, then break it down into bits - usually the header, navigation and footer of a page - which can then be saved as includes.
Hope that makes sense.
e-Raser
07-31-2005, 03:37 PM
If you're talking about dynamic links (index.php?x=page), you can do it two ways, with cases or with includes.
Wz886
07-31-2005, 03:44 PM
I know about about the Include option but how would I go about linking it all together. I mean the whole page would still have to reload wouldn't it?
BaDgEr
07-31-2005, 03:55 PM
I don't think you can get PHP to act like IFrames.
e-Raser
07-31-2005, 04:05 PM
The page would still have to load. Includes take the contents of the file included and puts it into the file as if it was typed in already. Do you know what I mean?
So maybe there's file.html wth the contents of
<html>
<head></head>
<body>
and you include it into a file called included.php, so the code's like this
<?php include("file.html"); ?>
Stuff here blah blah
</body>
</html>
If you go included.php and view the source, it'll be
<html>
<head></head>
<body>
Stuff here blah blah
</body>
</html>
Fou-Lu
07-31-2005, 05:04 PM
Hello server, please send me a php page.
-Ok. Here you are.
Thank you, can you please modify it as follows:
-No, sorry I can't do that. In order to preform an alteration, please send me a new request. Thank you.
Lol.
Once php is sent if you need to change the way it looks/works, etc, you need to send it a new request for it. You can use a query string to alter your conditions.
Now, there are always exceptions of course. You can create a page as you are asking using smaller php pages included and javascript. It would consist mainly of downloading your content to individual divs and using style hide to not display them. Javascript can then display what you want when requested. This is not a php thing, but a javascript thing. This makes it unreliable. I've also seen a similar technique used with XML. That was pretty cool btw.
Otherwise, your looking at a different language, such as java or flash to do what you need.
BaDgEr
07-31-2005, 10:04 PM
Fou-Lu talks to .php files ^.^
Wz886
07-31-2005, 10:12 PM
I decided to let the whole page load, but I will use PHP to load content of the page from MySql.
Thanks for the input :thumbsup:
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.