i have index.php which has all the css done and i am echoing view_entry.php, which calls up posts to appear on index.php. Also, if there are more than 10 posts within a page it will create page 2 and post the 10 posts and etc. Now the problem is that when I go to the next page it moves out from index.php where all the css/html are done and I will have a blank page with 10 posts. How can I resolve this, so that if i go into page 2 it will have a consistent look as index.php.
Here are the codes:
index.php
<div id="content">
<?php include('view_entry.php'); ?>
</div>
view_entry.php
<?php
/*This script retrieves blog entries from the database. */
require_once('inc/config.inc'); //Include the configuration file for error management and such.
require_once ('scripts/mysql_connect.php'); //Connect to the database.
$display = 10;
//Determine how many pages there are.
if(isset($_GET['np'])) { //Already been determined.
$num_pages = $_GET['np'];
} else {
$query = 'SELECT * FROM stories ORDER BY date_entered DESC';
$query_result = mysql_query($query);
$num_records = @mysql_num_rows($query_result);
if($num_records > $display) {//More than 1 page.
$num_pages = ceil($num_records/$display);
} else {
$num_pages = 1;
}
}
//Determine where in the database to start returning results.
if(isset($_GET['s'])) {
$start = $_GET['s'];
} else {
$start = 0;
}
$query = "SELECT stories.name, stories.entry, DATE_FORMAT(stories.date_entered, '%M %e, %Y %T') AS d, stories.title, COALESCE(upload.path,'') AS path
FROM stories LEFT OUTER JOIN upload
ON stories.date_entered = upload.date_upload
ORDER BY date_entered DESC LIMIT $start, $display";
$result = @mysql_query($query);
$num = mysql_num_rows($result);
//Retrieve and print every record:
echo '<br/>';
while ($row = mysql_fetch_array($result)) {
echo '<div class="post"><h2 class="title"><a href="#">' .$row['title']. '</a></h2>';
echo '<p class="byline"><small>Posted on ' .$row['d']. ' by ' .$row['name']. '</small></p>';
if (!empty ($row['path']) )
{
echo '<img src="'.$row['path'].'"/>';
} else {
echo '';
}
echo '<div class="entry"><p>' .$row['entry']. '</p></div>';
echo '</div>';
}
if($num > 0) {
if($num_pages > 1) {
echo '<p>';
$current_page = ($start/$display) + 1;
if($current_page !=1) {
echo '<a href="view_entry.php?s=' .($start - $display). '&np=' .$num_pages.'">Previous </a>';
}
//Make all the numbered pages.
for($i = 1; $i <= $num_pages; $i++) {
if($i != $current_page) {
echo '<a href="view_entry.php?s=' .(($display * ($i - 1))). '&np=' .$num_pages. '">' . $i . ' </a>';
} else {
echo $i . ' ';
}
}
//If it's not the last page, make a next button.
if($current_page != $num_pages) {
echo '<a href="view_entry.php?s=' .($start + $display). '&np' .$num_pages.'"> Next</a>';
}
echo '</p><br/>';
} //End of links section.
}
mysql_close(); //Close the database connection.
?>
</body>
</html>