вот код с моего двигла на пхп
если конешно разберётесь, что врятли.. но всё же принцып сам
function cat_wiew($category)
{
global $db;
global $bbcode;
global $tpl;
global $login;
$i="0";
if ($category !== "all") {$count = $db->get_cell("SELECT COUNT('id') FROM " . PREFIX . "_states WHERE category='$category'");}
else {$count = $db->get_cell("SELECT COUNT('id') FROM " . PREFIX . "_states");}
if ($count%10 != 0)$count = intval($count/10)+1; else $count = intval($count/10);
if(isset($_POST['page'])) $page = $_POST['page']; else $page=1;
$page1 = $page*10-10;
$page2 = $page1 + 9;
$content = "";
if ($category !== "all") {
$query = "SELECT id, date, author, content, title FROM " . PREFIX . "_states WHERE category='$category' ORDER BY id DESC LIMIT $page1, $page2";}
else {$query = "SELECT id, date, author, content, title FROM " . PREFIX . "_states ORDER BY id DESC LIMIT $page1, $page2";}
$res = mysql_query($query) or die("Query failed : " . mysql_error());
while ($row = mysql_fetch_assoc($res)) {
if ($row['author'] == $login) {
$mod_options = '1';}
else $mod_options = "2";
$temp = $tpl->sub_load_template('category.tpl');
$content .= preg_replace('/{auth}/', "<a name=\"id_".$row["id"]."\"></a>" . $row['author'], $temp);
}
mysql_free_result($res);
$content = $bbcode->bbcode2html($content);
$content .="<br><center><form method=\"post\" action=\"index.php?act=cat&des=$category\">";
if ($count > 4) {
$content .= "<input type=\"submit\" name=\"page\"value=\"". $page-1 . "\">";
$content .= "<input type=\"submit\" name=\"page\"value=\"$page\">";
$content .= "<input type=\"submit\" name=\"page\"value=\"". $page+1 . "\">";
$content .= "<input type=\"submit\" name=\"page\"value=\"$count\">";
}
else {while ($i<$count) {$i +=1; $content .= "<script language=\"Javascript\">var count=\"$count\";var page=\"$page\";</script><input type=\"submit\" name=\"page\"value=\"$i\">";}}
$content .= "</form></center>";
return $content;
}
вообще пм напишите я скину свой номер аськи и дам весь код