View Full Version : Replacing a single <div>'s contents

07-18-2007, 01:08 AM
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"


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,


07-18-2007, 02:45 AM
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.*


*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.