Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Replacing a single <div>'s contents

    Here is an example to visually show the situation: http://www.cashmgmt.com/new.0/about.php

    The main contents for the About page (within the white portion of the page and contained within <div id="content">) are included using a standard <?php include(""); ?>. The idea here is of course to have a page that remains in place without having to load anew every time you click a link. I would like to replace these contents (within the white section) with external pages when you click a link (such as Home, Contact, or About) by ONLY REPLACING that white section.


    Since I have virtually no knowledge of PHP coding, I am going to try to just explain what I essentially have in my head for something I might need...

    Something along these lines: "on clicking a link, replace contents of <div id="content"> with contact.php"

    -or-

    include a variable in <?php include(""); ?> (such as <?php include("variable"); ?>) and do something along these lines: on clicking the link, variable="contact.php" and on clicking another link variable="home.php"


    That was just my attempt to explain what I'm trying to do a little more easily (though I'm sure it made things worse ). What PHP/XML functions do I need to make this happen, and what do I need to use in the href property to call these functions? I have never done anything along these lines before, and am unfortunately in need of a beginner's explanation . I have seen this done extremely often, so I imagine there is a relatively simple solution it is this simplest solution that I am looking for.

    Thank you for taking the time to read this incredibly long request! Time is of the essence, and any help would be GREATLY appreciated. Thank you very much in advance,

    Carl

  • #2
    Senior Coder whizard's Avatar
    Join Date
    Jan 2005
    Location
    Philadelphia, PA, USA
    Posts
    1,662
    Thanks
    14
    Thanked 76 Times in 76 Posts
    PHP code is processed by the server before sending the page to the client (browser). Therefore, PHP cannot interact with the user without a reload.*

    Dan

    *It can technically be done using AJAX, a combination of PHP and JavaScript, which is an advanced concept beyond the scope of my explanation, but it cannot be done with PHP alone.
    PHP Tip: If you want to use short tags (<? or <?=$var) then make sure short_open_tag is set to "1". It really helps.

    Don't forget to save everyone time and mark your thread as Resolved :)

    "Also note that it is your responsibility to die() if necessary."

    DON'T USE THE MYSQL_ EXTENSION


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •