Stop reloading the whole page.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pavlos1316
Forum Newbie
Posts: 6
Joined: Mon Jun 02, 2008 4:17 am

Stop reloading the whole page.

Post by Pavlos1316 »

My index.php:

Code: Select all

<body>
<div id="header">
<?php include('header.php'); ?>
</div>
<div id="content">
<?php
	$page = $_GET['page'];
	if (!empty($page)) {
		$page .= '.php';
		include($page);
	}
	else {
		include('arxiki.php');
	}
?>
</div>
<div id="footer">
<?php include('footer.php'); ?>
</div>
My <div id=header> link:

Code: Select all

<a href="index.php?page=body" class="difflink">Body</a>
I use this code to open the link BODY which is in my <div id=header> into my <div id=content>.
BUT when it happens my whole page gets reloaded. How can I stop this and have only my <div id=content> reloaded?
oscardog
Forum Contributor
Posts: 245
Joined: Thu Oct 23, 2008 4:43 pm

Re: Stop reloading the whole page.

Post by oscardog »

Why wouldn't you want the whole page to reload? It looks like a CMS-style setup, albeit it a simple one.

If you don't want the page to reload you'll either need to use an iFrame, and simply reload the content in that iFrame or use AJAX.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Stop reloading the whole page.

Post by califdon »

It depends on what is in those page files. If each one has a header and/or an HTML or BODY tag, of course it's going to reload, since that's what you're asking it to do. If those files contain nothing but HTML to be placed within the content DIV, I don't see why it would reload.
Post Reply