Forum Moderators: coopster
<?php
include('dbconnect.php');
$totalrows = 10;
$rr = mysql_query("SELECT count( * ) as total_record FROM posts") or die(mysql_error());
while ($row = mysql_fetch_object($rr)) {
$count = $row->total_record;
if(!isset($_GET['p'])) { $_GET['p'] = ""; }
if($_GET['p'] == "") { $page = 1; } else { $page = $_GET['p']; }
if($_GET['p'] == 0) { $page = 1; }
if($_GET['p'] > ($count / $totalrows)) { $page = 1; }
if($page == 1) { $pstart = 0; } else { $pstart = $page * $totalrows; }
$pend = $pstart + $totalrows;
$sql = "SELECT posts.Tags as tags, posts.OwnerUserId as postsid, posts.Id as postid, posts.Body as body, posts.Title as title, users.Id as userid, users.DisplayName as usersname FROM posts JOIN users ON posts.OwnerUserId = users.Id WHERE posts.Id >= " . $pstart . " AND posts.Title != '' ORDER by posts.Id AND posts.Id ASC LIMIT " . $totalrows;
//echo $sql;
$r = mysql_query($sql) or die(mysql_error());
}
$count = intval($count / $totalrows);
?>