Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 1.31 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.                                                 $con = mysql_connect("localhost","raylour_user","shadazy");
  3.                                                 if(!con) {
  4.                                                         die('Error: Could not connect to database');
  5.                                                 }
  6.                                                 mysql_select_db("raylour_site", $con);
  7.                                                 $result = mysql_query("SELECT * FROM sitenews ORDER BY num DESC");
  8.                                                 $lastpostnum = -1;
  9.                                                 $pagenum = $_GET["page"];
  10.                                                 if($pagenum<=0 or $pagenum==NULL){
  11.                                                         $pagenum = 1;
  12.                                                 }
  13.                                                 while($row = mysql_fetch_array($result)){
  14.                                                         if($lastpostnum==-1){
  15.                                                                 $lastpostnum = $row['num']-9-(($pagenum-1)*10);
  16.                                                                 $firstpostnum=$lastpostnum+9;
  17.                                                         }
  18.                                                         if($row['num']<=$firstpostnum){
  19.                                                                 echo "<h1>" . $row['header'] . "</h1>";
  20.                                                                 echo "<p class='time'>" . $row['time'] . "</p>";
  21.                                                                 echo "<p>" . $row['body'] . "</p>";
  22.                                                                 echo "<p class='author'>" . $row['author'] . "</p>";
  23.                                                         }
  24.                                                         if($row['num']==$lastpostnum){
  25.                                                                 if($pagenum!=1) {
  26.                                                                         $newpagenum = $pagenum - 1;
  27.                                                                         echo "<a href='sitenews.php?page=" . $newpagenum . "' class='previouspage'>Previous Page</a>";
  28.                                                                 }
  29.                                                                 if($row['num']!=1){
  30.                                                                         $newpagenum = $pagenum + 1;
  31.                                                                         echo "<a href='sitenews.php?page=" . $newpagenum . "' class='nextpage'>Next Page</a>";
  32.                                                                 }
  33.                                                                 mysql_close($con);
  34.                                                                 exit;
  35.                                                         }
  36.                                                 }
  37.                                                 mysql_close($con);
  38.                                         ?>