mira el tema que con mssql y php no hay nada en paginacion porque es un lio , esta clase la encontre y anda bien el tema es la impresion que es muy engorrosa asi. pongo la clase entera que es chica a ver si alguien que sepa mucho o vos puede hacer que la salida de los datos sea mas manejable que seria lo unico que le faltaria.
Código PHP:
require('db_config.php');
error_reporting(E_ALL); // only for testing
class MssqlPagina {
var $sql;
var $result;
var $get_var = QS_VAR;
var $num_per_page = NUM_ROWS; //Records per page
var $tot_num_rows; //Total number of rows
var $page_no; //Current page no
var $num_of_pages; //No of Pages
var $seek; //Position where we have to display records
// constructor
function MssqlPagina() {
$this->connect_db();
}
// database connection
function connect_db() {
$conn_str = mssql_connect(DB_SERVER, DB_USER, DB_PASSWORD);
mssql_select_db(DB_NAME, $conn_str);
}
// sets the current page number
function set_page() {
$this->page_no = (isset($_REQUEST[$this->get_var]) && $_REQUEST[$this->get_var] != "") ? $_REQUEST[$this->get_var] : 0;
return $this->page_no;
}
// gets the total number of records
function get_total_rows() {
$tmp_result = mssql_query($this->sql);
$this->tot_num_rows = mssql_num_rows($tmp_result);
mssql_free_result($tmp_result);
return $this->tot_num_rows;
}
// get the total number of result pages
function get_num_pages() {
$this->num_of_pages = ceil($this->get_total_rows() / $this->num_per_page);
return $this->num_of_pages;
}
// returns the records for the current page
function get_page_result() {
if( $this->set_page() != 0 ){
$this->seek = $this->set_page() * $this->num_per_page;
//$seek++;
}
$this->result = mssql_query($this->sql);
mssql_data_seek($this->result, $this->seek);
//return $this->result;
for($rv=1;$rv<=$this->num_per_page;$rv++){
$row=mssql_fetch_row($this->result);
$returnarray[]=$row;
//echo "{$row[0]}-{$row[1]}<br>";
}
return $returnarray;
}
// function to handle other querystring than the page variable
function rebuild_qs($curr_var) {
if (!empty($_SERVER['QUERY_STRING'])) {
$parts = explode("&", $_SERVER['QUERY_STRING']);
$newParts = array();
foreach ($parts as $val) {
if (stristr($val, $curr_var) == false) {
array_push($newParts, $val);
}
}
if (count($newParts) != 0) {
$qs = "&".implode("&", $newParts);
} else {
return false;
}
return $qs; // this is your new created query string
} else {
return false;
}
}
// function to show navigation
function show_navigation($displayname = "Page"){
$var = $this->get_var;
for($PageCount=0;$PageCount<$this->get_num_pages();$PageCount++)
{
echo " | ";
echo "<a href=\"".$_SERVER['PHP_SELF']."?".$this->get_var."=".$PageCount.$this->rebuild_qs($var)."\">$displayname ".($PageCount+1)."</a>";
echo " | ";
}
}
// free the database result
function free_page_result() {
mssql_free_result($this->result);
}
}
desde ya muchisimas gracias...