
Untitled
By: a guest on
May 5th, 2012 | syntax:
None | size: 1.31 KB | hits: 7 | expires: Never
<?php
$con = mysql_connect("localhost","raylour_user","shadazy");
if(!con) {
die('Error: Could not connect to database');
}
mysql_select_db("raylour_site", $con);
$result = mysql_query("SELECT * FROM sitenews ORDER BY num DESC");
$lastpostnum = -1;
$pagenum = $_GET["page"];
if($pagenum<=0 or $pagenum==NULL){
$pagenum = 1;
}
while($row = mysql_fetch_array($result)){
if($lastpostnum==-1){
$lastpostnum = $row['num']-9-(($pagenum-1)*10);
$firstpostnum=$lastpostnum+9;
}
if($row['num']<=$firstpostnum){
echo "<h1>" . $row['header'] . "</h1>";
echo "<p class='time'>" . $row['time'] . "</p>";
echo "<p>" . $row['body'] . "</p>";
echo "<p class='author'>" . $row['author'] . "</p>";
}
if($row['num']==$lastpostnum){
if($pagenum!=1) {
$newpagenum = $pagenum - 1;
echo "<a href='sitenews.php?page=" . $newpagenum . "' class='previouspage'>Previous Page</a>";
}
if($row['num']!=1){
$newpagenum = $pagenum + 1;
echo "<a href='sitenews.php?page=" . $newpagenum . "' class='nextpage'>Next Page</a>";
}
mysql_close($con);
exit;
}
}
mysql_close($con);
?>