rendered paste body<?php include(CONNECTION HERE!); $limit = 6; $query_count = "SELECT count(*) FROM news"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); $page = intval($_GET['page']); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM news LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } echo("<table width='100%'>"); while($row = mysql_fetch_array($result)){ echo("<tr><td><h4>"); echo($row["title"]); echo(" <small>"); echo($row["date"]); echo("</small></h4></td></tr>"); echo("<tr><td>"); echo($row["body"]); echo("</td></tr><tr><td>Posted By: "); echo($row["poster"]); echo("</td></tr><hr>"); } echo("</table>"); if($page != 1){ $pageprev = $page--; echo("<a href=\"$PHP_SELF&page=$pageprev\">PREV </a> "); }else{ echo("PREV "); } $numofpages = $totalrows / $limit; for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows % $limit) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } if(($totalrows - ($limit * $page)) > 0){ $pagenext = $page++; echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT </a>"); }else{ echo("NEXT"); } mysql_free_result($result);?>