All pastes #46636 Raw Edit

Untitled

public text v1 · immutable
#46636 ·published 2006-03-22 20:04 UTC
rendered paste body
<?php
$total = 41; //This is actually gotten from the database
if(!$total){
  //Send an error message
}else{
  echo '<table>';
  //  echo '<tr><th>Title</th><th>Subtitle</th><th>Comments</th><th>date</th></tr>';
  $page = empty($_GET['page'])?1:$_GET['page'];
  $page = (is_numeric($page) && $page > 0)?$page:1;
  $perpage = 20;
  for($start = ($page-1) * $perpage;$start > $total;$start = ($page-1) * $perpage)
    $page--;
  $posts = $post->list_posts($perpage, $start, $user->information['id']);
  if(!$posts){
    //Send error message
  }else{
    foreach($posts as $c){
      //Print the information
    }
    for($i=1;($i-1)*$perpage <= $total;$i++){
      if($i != $page)
	echo '[<a href="/?posts&page='.$i.'">'.$i.'</a>]';
      else
	echo '.'.$i.'.';
    }
  }
}
?>