Jump to content

how to load new links without reloading page


Yamaha32088

Recommended Posts

I am new to php/mysql. My website I am working on is www.marketlistads.com its just a template im modyfying but i first got to get the code to work. What im wondering is if there is a way to create something like a container that will reload anylink clicked on in it so that it doesnt reload the entire page and so I dont have to create 32 or more pages that are exactly the same just with the body being a little different. An example in case thats not clear enough is basically a left sided frame set I have never worked with Iframes or Framesets before but I have heard bad things about them. I want the user to be able to click on the links from the left navigation menu and not have to watch the entire page reload. Plus its a pain duplicating the same page over and over only to change a few pictures around. Anyhelp would greatly be appreciated.

Link to comment
Share on other sites

maybe create like a header file and a footer file... (header.php, footer.php)

then on each page have...


<?php include('header.php'); ?>

body of page....

<?php include('footer.php'); ?>

 

Then each page will have the same header/footer or whatever... throw in a menu.php or whatever you need.

Link to comment
Share on other sites

Use HTTP_GET_VARS?

Link example:

<a href="?page=Guestbook">My Guestbook</a>

 

The page:

<html><head><title>Your title</title></head><body>
<?php
if(!$_GET['page'])
{
echo "This is our front/home page.<br />";
}
elseif($_GET['page'] == "Guestbook")
{
echo "Welcome to my Guestbookm feel free to read it and write in it!";
}
?>

Link to comment
Share on other sites

This is really easy. Just make a folder called template and put your template in it as index.php:

 

<html> 
all the styles and stuff
<body>

<php? content(); ?>

</body>
</html>

 

Now make an includes folder and put in main.php and hompage.php and so on and so on(these are were your content goes):

 

<?php
content() {

if(!$_GET['page'])
{
include('hompage.php')
}
elseif($_GET['page'] == "other")
{
include('otehr.php');
}

}
?>

 

Finally we will add the index page. So on your root put index.php:

 

<php
include('includes/main.php');
include('template/index.php');
?>

 

And thats that. Hope it helps. :)

 

Caution: I wrote the code on the fly probably errors

 

PS: visit my site Ravingredgames.com

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.