Location: PHPKode > projects > Mdasx > mdasx/posts.php
<?php

/*Vitaly Fedulov leoxs.com
  Downloads mdasx.sourceforge.net
  Version 0.1beta License GNU/GPL       */

require_once ("includes/hawhaw.inc");
require_once ("includes/config.php");
$blogtitle = "Posts";
include_once ("includes/header.php");

mysql_connect($dbhost, $dbuname, $dbpass);
@mysql_select_db("$dbname") or die ("MySQL ERROR");

$num = $num_posts;
$page = $_GET['page'];
$result = mysql_query("SELECT ID FROM `".$prefix."_posts` WHERE post_status='publish' AND post_type='post'");
$post = mysql_num_rows($result);
$total = intval(($post-1)/$num) + 1;
$page = intval($page);
if(empty($page) or $page < 0) $page = 1;
if($page > $total) $page = $total;
$start = $page * $num - $num;

$result = mysql_query("SELECT ID,post_title,post_name FROM `".$prefix."_posts` WHERE post_status='publish' AND post_type='post' ORDER  BY post_date DESC LIMIT $start, $num");
$x = 0;
while ($postrow[] = mysql_fetch_array($result)) $x++;
for($i = 0 ; $i < $num; $i++ )
{if($i == $x) break;
$title=$postrow[$i]['post_title'];
$id=$postrow[$i]['ID'];
$name = $postrow[$i]['post_name'];
$Link = new HAW_link($title,"read.php?m=".$id."&n=".$name,$title);
$Image = new HAW_image("images/default/post.wbmp","images/default/post.gif","->","images/default/post.bmp");
$Page->add_image($Image);
$Page->add_link($Link);
}

if ($page != 1) {
$Link = new HAW_link("Back","$_SERVER[PHP_SELF]?page=".($page - 1),"Back");
$Link->set_br(0);
$Image = new HAW_image("images/default/nav_back.wbmp","images/default/nav_back.gif","->","images/default/nav_back.bmp");
$Page->add_image($Image);
$Page->add_link($Link);
}
if ($page != $total) {
$Link = new HAW_link("Next","$_SERVER[PHP_SELF]?page=".($page + 1),"Next");
$Link->set_br(2);
$Image = new HAW_image("images/default/nav_forward.wbmp","images/default/nav_forward.gif","->","images/default/nav_forward.bmp");
$Page->add_image($Image);
$Page->add_link($Link);
}
mysql_close();

include_once ("includes/footer.php");
?>
Return current item: Mdasx