Hi all
I have been following a tutorial on pagination. Although, like most of these pagination tutorials, they are relatively easy to follow, they dont tell you you how or where to put the code to actually display the results on the page. If they do then I am totally stupid and am missing the point.
Please could someone look at the code and tell me wher i put my layout and fields so I can actually see something on the page othere than the page numbers.
I am guessing that the pagination is working because i have page numbers on the page but no detail.
This is the code as followed in the tutorial.
<?php
if($_GET['page']) // Is page defined?
{
$page = $_GET['page']; // Set to the page defined
}else{
$page = 1; // Set to default page 1
}
$max = 10; // Set maximum to 10
$cur = (($page * $max) - $max); // Work out what results to show
$getdata = mysql_query("SELECT id, title, detail, DATE_FORMAT(date,'%a %D %M %Y \at %H\:%i ') as date FROM lindablog ORDER BY id DESC LIMIT $cur, $max") or die(mysql_error()); // select the results
$data = mysql_fetch_array($getdata); // get the data
$counttotal = mysql_query("SELECT * FROM lindablog ") or die(mysql_error()); // select all records
$counttotal = mysql_num_rows($counttotal); // count records
$total_pages = ceil($counttotal / $max); // dive the total, by the maximum results to show
if($page > 1){ // is the page number more than 1?
$prev = ($page - 1); // if so, do the following. take 1 away from the current page number
echo '<a href="?page=' . $prev . '">« Previous</a>'; // echo a previous page link
}
for($i = 1; $i <= $total_pages; $i++) // for each page number
{
if($page == $i) // if this page were about to echo = the current page
{
echo'<b>' . $i .'</b> '; // echo the page number bold
} else {
echo '<a href="?page=' . $i . '">' . $i . '</a> '; // echo a link to the page
}
}
if($page < $total_pages){ // is there a next page?
$next = ($page + 1); // if so, add 1 to the current
echo '<a href="?page=' . $next . '">Next »</a>'; // echo the next page link
}
?>
This is the code i have to display my info on the page. Currently it is just displaying one ater the other in a quite long page.
// This is where i thought my code would go
// Start The Layout Of The blog System
echo '<tr><td><img src="images/tophead.jpg" width="600" height="18" alt="" /></td></tr>';
echo '<tr class="conttitle"><td>';
echo ' <table align="center" width="550"><tr><td align="center"><span class="newstitle">';
echo "$title";
echo ' </span></td></tr></table>';
echo ' </td></tr><tr class="contbody"><td>';
echo ' <table align="center" width="540"><tr><td><span class="date">';
echo "$date";
echo ' </td></tr><tr><td><span class="blog">';
echo " $detail";
echo ' </span></td></tr></table>';
echo '</td></tr>';
echo '<tr><td colspan="2" ><a href="admin/admin.php?page=main"><img src="images/foot.jpg" border="0" width="600" height="26" alt="" /></a></td></tr>';
//my stuff ends
i would be very grateful if someone could show me how to incorporate my info in to the code.
Many thanks
ps: I have tried putting it in myself and have yet to see anything displayed other than the page numbers