Web Analytics Made Easy -
StatCounter Dynamic Pages - CodingForum

Announcement

Collapse
No announcement yet.

Dynamic Pages

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Dynamic Pages

    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.

  • #2
    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.

    Comment


    • #3
      If you're talking about dynamic links (index.php?x=page), you can do it two ways, with cases or with includes.
      I lost my signature, have you seen it?
      I have the power to erase you...

      Comment


      • #4
        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?

        Comment


        • #5
          I don't think you can get PHP to act like IFrames.

          Comment


          • #6
            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
            Code:
            <html>
            <head></head>
            <body>
            and you include it into a file called included.php, so the code's like this
            Code:
            <?php include("file.html"); ?>
            Stuff here blah blah
            </body>
            </html>
            If you go included.php and view the source, it'll be
            Code:
            <html>
            <head></head>
            <body>
            Stuff here blah blah
            </body>
            </html>
            I lost my signature, have you seen it?
            I have the power to erase you...

            Comment


            • #7
              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.
              PHP Code:
              header('HTTP/1.1 420 Enhance Your Calm'); 
              Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)

              Comment


              • #8
                Fou-Lu talks to .php files ^.^

                Comment


                • #9
                  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

                  Comment

                  Working...
                  X