<?
 
 
  mysql_connect("localhost","myuser","mypasswd");
 
  mysql_select_db("mydb");
 
  // this is a dump variable just for demonstration purposes
 
  $cod= 5;
 
 
  // how many rows do you want per page???
 
  $step = 20;
 
  
 
?>
 
<center>
 
  <h1>Class : pn_class.<br> Create previous - next buttons </h1>
 
<?
 
 
  # Include class file
 
  include ("pn.class.php");
 
 
  # the sql query without Limit
 
  $sql = "select creativeid, name, campaignid from ad_creatives";
 
  # initiate class
 
  # parameters explanation
 
  # 1st param : the sql query without Limit expretion
 
  # 2nd param : number of elements to display per page.
 
  # 3rd param : current page; this should be null
 
  $buttons = new pn_buttons( $sql, $step, $page );
 
 
  # $buttons->limited_query is the sql query with limit expretion
 
  # class create this
 
  $res = mysql_query ($buttons->limited_query);
 
 
  # list elements
 
  while ( list ( $id, $name, $value ) = mysql_fetch_row($res) ){
 
      echo "$id - $name - $value<br>";
 
  }
 
  
 
  # Create Prev and next buttons
 
  # parameters explanation
 
  # 1st param : the page that displays results with ?  at the end
 
  # 2nd param : additional url parameters e.g. cid=$cid&top=$top
 
  # 3rd param : Text to display in next link
 
  # 4th param : Text to display in previous link
 
  $buttons->make_buttons("index.php?","cid=$cod","Επόμενα >>", "<< Προηγούμενα");
 
 
  # display previous and next links
 
  echo $buttons->previous_button . "    " .$buttons->next_button;
 
 
  # display current page number and total pages number
 
  echo "<br><br>Page ". $buttons->current_page . " of  ". $buttons->query_total_pages;
 
  echo "<br><br><br>";
 
  echo  $buttons->count_all_pages("index.php?","cid=$cid");
 
  
 
?>
 
</center>
 
 |