hi. i wonder if someone could check this script for me and tell why it isn't producing any results. here is the code:

<?php
function ShowMyFiles() {
  
    // vars global configuration
    global $dbConn, $theme_path;

    // vars messages
    global $msg;
    // vars template
    global $error_msg, $status, $files, $owner, $test, $paginated;
	
    if ($err) {
      $error_msg = 'Custom error message';
    }
	
	if(!isset($_GET['page'])){
    $page = 1;
	} else {
    $page = $_GET['page'];
	}
	
    // get variable after selecting something from the dropdown with name 'chooser'
	$select = $_POST['select'];
	

	// if something has been chosen
	if (!empty($select)) {
	
	// get the chosen value
	$chooser = $_POST['chooser'];
	
	// Define the number of results per page
	$max_results = 10;
	
	// Figure out the limit for the query based
	// on the current page number.
	$from = (($page * $max_results) - $max_results);
    
    // get file listing
    // if everything successful create query
	// this selects all rows where the type is the one you chose in the dropdown
	// * means that it will select all columns, ie name and type as i said above
	
	$sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";
   	$result  = $dbConn->Execute($sql) or die(mysql_error());
	
	
	// Figure out the total number of results in DB:
	$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM idx_reslink WHERE category_id='$chooser'"),0);
	
	
	// Figure out the total number of pages. Always round up using ceil()
	$lastpage = ceil($total_results / $max_results);
	
	
	
	global $paginated;
    $paginated .= "<center>Select a Page<br />";
    
    if ($page == 1) {
    $paginated .= " FIRST PREV ";
    } else {
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
       $prevpage = $page-1;
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
    } 
    $paginated .= " ( Page $page of $lastpage ) ";
    
    if ($page == $lastpage) {
   $paginated .= " NEXT LAST ";
    } else {
   $nextpage = $page+1;
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
    }
	
	$test = '';
   	for($i = 0;$i < $result->RecordCount(); $i++){
   	$file = $result->Fields("title");
   	$description = $result->Fields("description");
   	$date = $result->Fields("date");
   
   	$test .= '<table width="100%%"  border="0">
  	<tr>
    <td></td>
  	</tr>
	</table>

	<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
	<tr class="tbl_caption_mem">
  	<td width="12%"><strong>Title</strong></td>
  	<td width="73%"><strong>Description</strong></td>
  	<td width="15%"><strong>Date Added</strong></td>
	</tr>
	<tr class="tbl_caption_mem">
  	<td valign="top">'.$file.'</td>
  	<td valign="top">'.$description.'</td>
  	<td valign="top">'.$date.'</td>
  	</tr>
  	</table> <br />';
	
  	$result->movenext();
	}
  	}
  	$files = $test;
   		DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");
  	}

  	/*===================================================
    main
  	===================================================*/

  	include "../application.php";

  	RunPreFilter(__FILE__);

  	ShowMyFiles();

  	RunPostFilter(__FILE__);

?>

it produces the number of pages, but when user clicks on next, it goes to next page but blank screen. this is part of a dropdown menu and the form is passing select into this script. many thanks.

can no-one offer any assistance? thanks

this might help, i never could test it.

<?php
function ShowMyFiles() {
  
    // vars global configuration
    global $dbConn, $theme_path;

    // vars messages
    global $msg;
    // vars template
    global $error_msg, $status, $files, $owner, $test, $paginated;
	
    if ($err) {
      $error_msg = 'Custom error message';
    }
	
	if(!isset($_GET['page'])){
    $page = 1;
	} else {
    $page = $_GET['page'];
	}
	
    // get variable after selecting something from the dropdown with name 'chooser'
	$select = $_POST['select'];
	

	// if something has been chosen
	if (!empty($select)) {
	
	// get the chosen value
	$chooser = $_POST['chooser'];
	
	// Define the number of results per page
	$max_results = 10;
	
	// Figure out the limit for the query based
	// on the current page number.
	$from = (($page * $max_results) - $max_results);
    
    // get file listing
    // if everything successful create query
	// this selects all rows where the type is the one you chose in the dropdown
	// * means that it will select all columns, ie name and type as i said above
	
	$sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";
   	$result  = mysql_query($sql) or die(mysql_error());
	
	
	// Figure out the total number of results in DB:
	$total_results = mysql_num_rows($result);
	
	
	// Figure out the total number of pages. Always round up using ceil()
	$lastpage = $total_results / $max_results;
	
	
	
	global $paginated;
    $paginated .= "<center>Select a Page<br />";
    
    if ($page == 1) {
    $paginated .= " FIRST PREV ";
    } else {
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
       $prevpage = $page-1;
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
    } 
    $paginated .= " ( Page $page of $lastpage ) ";
    
    if ($page == $lastpage) {
   $paginated .= " NEXT LAST ";
    } else {
   $nextpage = $page+1;
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
    }
	
	$test = '';
while ($row = mysql_fetch_assoc($result)) {
   	$file = $row['title'];
   	$description = $row['description'];
   	$date = $row['date'];
   
   	$test .= '<table width="100%%"  border="0">
  	<tr>
    <td></td>
  	</tr>
	</table>

	<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
	<tr class="tbl_caption_mem">
  	<td width="12%"><strong>Title</strong></td>
  	<td width="73%"><strong>Description</strong></td>
  	<td width="15%"><strong>Date Added</strong></td>
	</tr>
	<tr class="tbl_caption_mem">
  	<td valign="top">'.$file.'</td>
  	<td valign="top">'.$description.'</td>
  	<td valign="top">'.$date.'</td>
  	</tr>
  	</table> <br />';
	
  	$result->movenext();
	}
  	}
  	$files = $test;
   		DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");
  	}

  	/*===================================================
    main
  	===================================================*/

  	include "../application.php";

  	RunPreFilter(__FILE__);

  	ShowMyFiles();

  	RunPostFilter(__FILE__);

?>

Just tell me any errors and i can fix them

thank you ever so much for your help kkeith. however, i get this error:

Fatal error: Call to a member function movenext() on a non-object in C:\wamp\www\public_html\cp\data.php on line 102

this line refers to this statement

$result->movenext();

If i remove that statement, then the pagination only shows page 1of1 and no links. there should be links. there are over 700 entries that should be coming back.
Thanks for continuing help kkeith.

well that line is referring to a function you did not post. if you know where it is post it. otherwise i will rewrite the code so it works. ill post it soon

i think i have solved your problem. i also remade the code without all the globals and template stuff.

Original Code Fixed (I think):

<?php
function ShowMyFiles() {
  
    // vars global configuration
    global $dbConn, $theme_path;

    // vars messages
    global $msg;
    // vars template
    global $error_msg, $status, $files, $owner, $test, $paginated;
	
    if ($err) {
      $error_msg = 'Custom error message';
    }
	
	if(!isset($_GET['page'])){
    $page = 1;
	} else {
    $page = $_GET['page'];
	}
	
    // get variable after selecting something from the dropdown with name 'chooser'
	$select = $_POST['select'];
	

	// if something has been chosen
	if (!empty($select)) {
	
	// get the chosen value
	$chooser = $_POST['chooser'];
	
	// Define the number of results per page
	$max_results = 10;
	
	// Figure out the limit for the query based
	// on the current page number.
	$from = (($page * $max_results) - $max_results);
    
    // get file listing
    // if everything successful create query
	// this selects all rows where the type is the one you chose in the dropdown
	// * means that it will select all columns, ie name and type as i said above

	$sql1 = "SELECT * FROM idx_reslink WHERE category_id = '" . $chooser . "'";
	$result1 = mysql_query($sql1);
	
	$sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";
   	$result  = mysql_query($sql) or die(mysql_error());
	
	
	// Figure out the total number of results in DB:
	$total_results = mysql_num_rows($result1);
	
	
	// Figure out the total number of pages. Always round up using ceil()
	$lastpage = $total_results / $max_results;
	
	
	
	global $paginated;
    $paginated .= "<center>Select a Page<br />";
    
    if ($page == 1) {
    $paginated .= " FIRST PREV ";
    } else {
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
       $prevpage = $page-1;
       $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
    } 
    $paginated .= " ( Page $page of $lastpage ) ";
    
    if ($page == $lastpage) {
   $paginated .= " NEXT LAST ";
    } else {
   $nextpage = $page+1;
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
   $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
    }
	
	$test = '';
while ($row = mysql_fetch_assoc($result)) {
   	$file = $row['title'];
   	$description = $row['description'];
   	$date = $row['date'];
   
   	$test .= '<table width="100%%"  border="0">
  	<tr>
    <td></td>
  	</tr>
	</table>

	<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
	<tr class="tbl_caption_mem">
  	<td width="12%"><strong>Title</strong></td>
  	<td width="73%"><strong>Description</strong></td>
  	<td width="15%"><strong>Date Added</strong></td>
	</tr>
	<tr class="tbl_caption_mem">
  	<td valign="top">'.$file.'</td>
  	<td valign="top">'.$description.'</td>
  	<td valign="top">'.$date.'</td>
  	</tr>
  	</table> <br />';
	
	}
  	}
  	$files = $test;
   		DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");
  	}

  	/*===================================================
    main
  	===================================================*/

  	include "../application.php";

  	RunPreFilter(__FILE__);

  	ShowMyFiles();

  	RunPostFilter(__FILE__);

?>

Here is the remake without all the extras:

All you have to do is fill in the mysql database connect stuff at the top of the script to make it work i hope

<?php

function showFiles() {

$con = mysql_connect("localhost","username","password") or die('Couldn\'t connect to mysql');

mysql_select_db('db_name', $con) or die('Couldn\'t select database');

$page = $_GET['page'];

if (!isset($page) || $page == NULL) {
$page = 1;
}
else {
$page = $_GET['page'];
}

if ($_REQUEST['select'] !== NULL) {

$chooser = $_REQUEST['chooser'];
$num = 10;
$lim = $page * $num;
$lim = $lim - $num;

$sql = "SELECT * FROM idx_reslink WHERE category_id = '" . $chooser . "'";
$query = mysql_query($sql);
$tot = mysql_num_rows($query);

$sql = "SELECT title,description,date FROM idx_reslink WHERE category_id = '" . $chooser . "' LIMIT " . $lim . ", " . $num;
$query = mysql_query($sql);
$lpage = ($tot/$num);
$thispage = $_SERVER['PHP_SELF'];

if($page > 1) {
$prev = $page - 1;
$last = '<a href="' . $thispage . '?page=1">First</a> <a href="' . $thispage . '?page=' . $prev . '">PREV</a>';
}
if ($lpage > $page) {
$go = $page + 1;
$next = '<a href="' . $thispage . '?page=' . $go . '">NEXT</a> <a href="' . $thispage . '?page=' . $lpage . '">Last</a>';
}

echo '<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">';
echo '<tr><td width="12%"><strong>Title</strong></td><td width="73%"><strong>Description</strong></td><td width="15%"><strong>Date Added</strong></td></tr>';

while ($row = mysql_fetch_assoc($query)) {

$title = $row['title'];
$description = $row['description'];
$date = $row['date'];

echo '<tr><td valign="top">' . $title . '</td><td valign="top">' . $description . '</td><td valign="top">' . $date . '</td></tr>';

}

echo '<tr><td>' . $last . '</td><td colspan="2" align="right">' . $next . '</td></tr>';
echo '</table>';

}

mysql_close($con);

}

showFiles();

?>

kkeith. neither version work. both display pagination but when next is clicked, blank page. the function that the command $result->movenext(); is this:

function MoveNext() {
    if ($row = mysql_fetch_assoc($this->resultset)) {
      $this->current_row = $row;
      $this->EOF = false;
      return true;
    }
    else {
      $this->EOF = true;
      return false;
    }
  }]

i need to work within the template system of the first script because it is an integral part of the site in terms layout etc. if it would help, i can post the whole of the db.class file. thank you ever so much in trying to get this script to work and for your valuable time and effort. cheers

they both worked for me. i don't know what going on. i set up the mysql tables and everthing on my server. it displayed just fine. what would help me out if you posted your entire class. this would make it easier to see everything else going on.

db.class.php

<?

class DB_Connection {
  var $conn = null;
  var $debug = false;
  var $num_query = 0; 
  var $error_msg = "";
  var $affected_rows = 0;

  function DB_Connection($host, $username, $pwd, $db) {
    $this->Connect($host, $username, $pwd, $db);
  }

  function Connect($host, $username, $pwd, $db) {
    global $db_use_persistent;
    if ($db_use_persistent) {
      $this->conn = mysql_pconnect($host, $username, $pwd);
    }
    else {
      $this->conn = mysql_connect($host, $username, $pwd);
    }
    mysql_select_db($db, $this->conn);
  }

  function Execute($query) {
    $query = trim($query);
    $this->num_query++;
    if ($this->debug) {
      static $mysql_query_number;
      static $mysql_query_time;
      $mysql_query_number++;
      $time_start = (float) array_sum(explode(' ', microtime()));
    }
    $result = @mysql_query($query, $this->conn);
    if ($this->debug) {
      $time_end = (float) array_sum(explode(' ', microtime()));
      $time = $time_end - $time_start;
      $time = sprintf("%01.4f", $time);
      $mysql_query_time += $time;
      $mysql_query_time = sprintf("%01.3f", $mysql_query_time);
      if ($time > 1) {
        $time = "<b>$time [slow query]</b>";
      }
      if (preg_match('/^select/i', $query)) {
        $num_rows = @mysql_num_rows($result);
        echo "<table width='100%' border='1' cellspacing='1'><tr valign='top'><td width='70'>QUERY #$mysql_query_number: </td><td>$query (result : $num_rows, time : $time)</td><td align='right' width='30'>$mysql_query_time</td></tr></table>";
      }
      else {
        echo "<table width='100%' border='1' cellspacing='1><tr valign='top'><td width='70'>QUERY #$mysql_query_number: </td><td>$query (time : $time)</td></td><td align='right' width='30'>$mysql_query_time</td></tr></table>";
      }
      if (mysql_error()) {
        echo "<table width='100%' border='1' cellspacing='1><tr valign='top'><td width='70'><font color='red'><b>ERROR : </b></font></td><td><font color='red'><b>".mysql_error()."</b></font></td><td align='right' width='30'>$mysql_query_time</td></tr></table>";
      }
    }
    $this->error_msg = mysql_error();
    if ($this->error_msg) {
      return false;
    }
    else {
      if (preg_match("/^update|insert|delete/msi", $query)) {
        $this->affected_rows = @mysql_affected_rows($this->conn);
        return new DB_Resultset_empty();
      }
      else {
        return new DB_Resultset($result, $query);
      }
    }
  }

  function PageExecute($query, $pg_which, $pg_size) {
    if (!$pg_which) {
      $pg_which = 1;
    }
    $query_total = $query;
    if (!preg_match('/group by/msi', $query_total)) {
      $query_total = preg_replace("|select(.*?)from|ms", "select count(*) as c from", $query_total);
    }
    $result = $this->Execute($query_total);
    if (preg_match('/group by/msi', $query_total)) {
      $num_rows = $result->RecordCount();
    }
    else {
      $num_rows = ($result->Fields('c')) ? $result->Fields('c') : 0;
    }
    $start = ($pg_which - 1) * $pg_size;
    $query = $query . " limit $start, $pg_size";
    $result->Close();
    $result = $this->Execute($query);
    $result->num_rows = $num_rows;
    return $result;
  }

  function InsertID() {
    return @mysql_insert_id($this->conn);
  }

  function Close() {
    return true;
  }

  function FetchArray($query) {
    $result = $this->Execute($query);
    $arr = array ();
    while ($row = $result->FetchRow()) {
      $arr[] = $row;
    }
    $result->Close();
    return $arr;
  }

  function FetchOne($query) {
    $result = $this->Execute($query . ' limit 1');
    $row = $result->FetchRow();
    $result->Close();
    return $row;
  }

  function Lookup($field, $table, $where) {
    $result = $this->Execute("select $field from $table where $where limit 1");
    $value = $result->Fields($field);
    $result->Close();
    return $value;
  }

  function CountQuery() {
    return $this->num_query;
  }

  function ErrorMsg() {
    return $this->error_msg;
  }

  function AffectedRows() {
    return $this->affected_rows;
  }
}

class DB_Resultset {
  var $resultset = null;
  var $num_rows = null;
  var $num_field = null;
  var $current_row = null;
  var $EOF = true;
  var $query = null;

  function DB_Resultset(&$resultset, $query = '') {
    $this->resultset = $resultset;
    $this->query = $query;
    if (preg_match('/^select|show|describe|explain/msi', $query)) {
      $this->MoveNext();
    }
  }

  function RecordCount() {
    if (is_null($this->num_rows)) {
      $this->num_rows = @mysql_num_rows($this->resultset);
    }
    return $this->num_rows;
  }

  function FieldCount() {
    if (is_null($this->num_field)) {
      $this->num_field = mysql_num_fields($this->resultset);
    }
    return $this->num_field;
  }

  function FetchField($offset) {
    $field = mysql_fetch_field($this->resultset, $offset);
    $field->max_length = mysql_field_len($this->resultset, $offset);
    return $field; 
  }

  function MetaType($field_type) {
    switch($field_type) {
      case preg_match('/char/i', $field_type):
        return 'C';
      case preg_match('/int|float|double/i', $field_type):
        return 'I';
      case preg_match('/text/i', $field_type):
        return 'X';
      case preg_match('/blob/', $field_type):
        return 'B';
      default:
        return '';
    }
  }

  function Move($offset) {
    if (@mysql_data_seek($this->resultset, $offset)) {
      return $this->MoveNext();
    }
    else {
      return false;
    }
  }

  function MoveFirst() {
    return $this->Move(0);
  }

  function MoveLast() {
    return $this->Move($this->num_rows - 1);
  }

  function MoveNext() {
    if ($row = mysql_fetch_assoc($this->resultset)) {
      $this->current_row = $row;
      $this->EOF = false;
      return true;
    }
    else {
      $this->EOF = true;
      return false;
    }
  }

  function Fields($name) {
    return $this->current_row[$name];
  }

  function FetchRow() {
    if (!$this->EOF) {
      $row = $this->current_row;
      $this->MoveNext();
      return $row;
    }
    else {
      return false;
    }
  }

  function Close() {
    if ($this->resultset) {
      mysql_free_result($this->resultset);
    }
  }
}

class DB_Resultset_empty {
  var $resultset = null;
  var $num_rows = null;
  var $num_field = null;
  var $current_row = null;
  var $EOF = true;
  var $query = null;

  function DB_Resultset() {
    return true;
  }

  function RecordCount() {
    return 0;
  }

  function FieldCount() {
    return 0;
  }

  function FetchField($offset) {
    return false;
  }

  function MetaType($field_type) {
    return false;
  }

  function Move($offset) {
    return false;
  }

  function MoveFirst() {
    return false;
  }

  function MoveLast() {
    return false;
  }

  function MoveNext() {
    return false;
  }

  function Fields($name) {
    return false;
  }

  function FetchRow() {
    return false;
  }

  function Close() {
    return true;
  }
}


$ADODB_SESS_CONN = null;
$ADODB_SESS_MD5 = false;

class DB_Session {

  function Open($save_path, $session_name) {
    global $ADODB_SESS_CONN, $dbServer, $dbHostname, $dbUsername, $dbPassword, $dbName;
    //echo "open<br>";
    if (is_null($ADODB_SESS_CONN)) {
      $ADODB_SESS_CONN = new DB_Connection($dbHostname, $dbUsername, $dbPassword, $dbName);
    }
    return true;
  }

  function Close() {
    global $ADODB_SESS_CONN;
    //echo "close<br>";
    if (!is_null($ADODB_SESS_CONN)) {
      $ADODB_SESS_CONN->Close();
    }
    return true;
  }

  function Read($key) {
    global $ADODB_SESS_CONN, $ADODB_SESS_MD5;
    //echo "read<br>";
    $data = '';
    if ($ADODB_SESS_CONN) {
      $query = "select data from idx_sessions where sesskey = '$key' AND expiry >= " . time();
      $result = $ADODB_SESS_CONN->Execute($query);
      if ($result->RecordCount()) {
        $data = rawurldecode($result->Fields('data'));
      }
      $ADODB_SESS_MD5 = md5($data);
      $result->Close();
    }
    return $data;
  }

  function Write($key, $data) {
    global $ADODB_SESS_CONN, $ADODB_SESS_MD5;
    //echo "write<br>";
    if ($ADODB_SESS_CONN) {
      $lifetime = ini_get('session.gc_maxlifetime');
      if ($lifetime <= 1) {
        $lifetime = 1440;
      }
      $expiry = time() + $lifetime;
      if ($ADODB_SESS_MD5 !== false && $ADODB_SESS_MD5 == md5($data)) {
        $query = "update idx_sessions set expiry = '$expiry' where sesskey = '$key'";
      }
      else {
        $data = rawurlencode($data);
        $query = "replace into idx_sessions (sesskey, expiry, data) values ('$key', '$expiry', '$data')";
      }
      $ADODB_SESS_CONN->Execute($query);
    }
    return true;
  }

  function Destroy($key) {
    global $ADODB_SESS_CONN;
    //echo "detroy<br>";
    if ($ADODB_SESS_CONN) {
      $query = "delete from idx_sessions where sesskey = '$key'";
      $ADODB_SESS_CONN->Execute($query);
    }
		return true;
  }

  function GC($maxlifetime) {
    global $ADODB_SESS_CONN;
    //echo "gc<br>";
    if ($ADODB_SESS_CONN) {
      $query = "delete from idx_sessions where expiry < ".time();
      $ADODB_SESS_CONN->Execute($query);
      $query = "optimize table idx_sessions";
      $ADODB_SESS_CONN->Execute($query);
    }
    return true;
  }

  function Init() {
    //echo "init<br>";
    session_module_name('user');
    session_set_save_handler(
      array('DB_Session', 'Open'),
      array('DB_Session', 'Close'),
      array('DB_Session', 'Read'),
      array('DB_Session', 'Write'),
      array('DB_Session', 'Destroy'),
      array('DB_Session', 'GC')
    );
  }
}

DB_Session::Init();

?>

pagination.class.php

<?php

class navigator {
    var $pg_size    = 10;
    var $pg_which   = 1;
    var $cp_size    = 10;
    var $rec_count  = 0;
    var $rec_start  = 0;
    var $more_param = "";
    var $href       = "";
    var $page_file  = "";
    var $page_title = "";

    var $page_text  = "Pages";
    var $first_text = "[First]";
    var $last_text  = "[Last]";
    var $prev_text  = "[Prev]";
    var $next_text  = "[Next]";

    var $active_link_color  = "";
    var $disable_link_color = "gray";

    function init() {
      global $lang;
      $this->rec_start = ($this->pg_which - 1) * $this->pg_size;
      if ($lang['nav_page']) {
        $this->page_text = $lang['nav_page'];
      }
      if ($lang['nav_first']) {
        $this->first_text = $lang['nav_first'];
      }
      if ($lang['nav_last']) {
        $this->last_text = $lang['nav_last'];
      }
      if ($lang['nav_prev']) {
        $this->prev_text = $lang['nav_prev'];
      }
      if ($lang['nav_next']) {
        $this->next_text = $lang['nav_next'];
      }
    }

    function print_all() {
      $length = $this->rec_count;
      if ($length <= $this->pg_size) {
        return;
      }

      if (!is_numeric($this->pg_which)) {
        $this->pg_which = 1;
      }

      $pref = (strpos($this->href, "?") === FALSE) ? "?" : "&";
      $radius = floor($this->cp_size / 2 * $this->pg_size);
      $offset = ($this->pg_which - 1) * $this->pg_size;
      if ($offset < $radius) {
        $start = 0;
      }
      elseif ($offset <= $length - $radius) {
        $start = $offset - $radius;
      }
      else {
        $start = (floor($length / $this->pg_size) - $this->cp_size) * $this->pg_size + $this->pg_size;
        if ($start < 0) {
          $start = $this->pg_size;
        }
      }

      $out = "";
      if ($offset > 0) {
        if ($start > 1) {
          $out .= "<a href=\"" . $this->href . $pref . "pg_which=1$this->more_param\" style=\"color: $this->active_link_color\">". $this->first_text ."</a>\n";
        }
        $out .= "<a href=\"" . $this->href . $pref . "pg_which=" . ($this->pg_which - 1) . $this->more_param . "\" style=\"color: $this->active_link_color\">". $this->prev_text ."</a>\n";
      }

      for ($i = $start; (($i < $length) && ($i < $start + $this->cp_size * $this->pg_size)); $i += $this->pg_size) {
        if ($i == $offset) {
          $out .= "<font color=\"$this->disable_link_color\"><b>" . ($i / $this->pg_size + 1) . "</b></font>\n";
        }
        else {
          $out .= "<a href=\"" . $this->href . $pref . "pg_which=" . ($i / $this->pg_size + 1) . $this->more_param . "\" style=\"color: $this->active_link_color\">" . ($i / $this->pg_size + 1) . "</a>\n";
        }
      }

      if ($offset < $length - $this->pg_size) {
        $out .= "<a href=\"" . $this->href . $pref . "pg_which=" . ($this->pg_which + 1) . $this->more_param . "\" style=\"color: $this->active_link_color\">". $this->next_text ."</a>\n";
        if ((ceil($length/$this->pg_size) - 1) * $this->pg_size >= $i) {
          $out .= "<a href=\"" . $this->href . $pref . "pg_which=" . ceil($length/$this->pg_size) . $this->more_param . "\" style=\"color: $this->active_link_color\">". $this->last_text ."</a>\n";
        }
      }

      if (GetModRewriteStatus() == '1') {
        $this->apply_seo($out);
      }

      $out = $this->page_text . ": " . $out;

      return $out;

    }

    function apply_seo(&$out) {
      if ($this->page_file == "browse") {
        $src[] = "|\"browse.php\?pg_which=(\w*?)&cat=(\w*?)\"|mse";
        $replacement[] = "\$this->apply_browse_seo('\\1', '\\2')";
      }
      
      if (is_array($src)) {
        $out = preg_replace($src, $replacement, $out);
      }
    }

    function apply_browse_seo($page, $cat) {
      $page_title            = SEOReplace($this->page_title);
      $mod_rewrite_pattern   = GetModRewritePatternCategory();
      if (strpos($mod_rewrite_pattern, '{$cat_path}') === FALSE) {
        $mod_rewrite_pattern = str_replace('{$cat_name}', $page_title, $mod_rewrite_pattern);
        $mod_rewrite_pattern = str_replace('{$cat_id}', $cat, $mod_rewrite_pattern);
        $mod_rewrite_pattern = str_replace('{$page}', $page, $mod_rewrite_pattern);
        $out                 = strtolower($mod_rewrite_pattern);
      }
      else {
        $page_text = substr(strrchr($mod_rewrite_pattern, '/'), 1);
        $out = $_SERVER['REQUEST_URI'];
        if (strpos($out, '.html') !== FALSE) {
          $outs = explode('/', $out);
          unset($outs[@count($outs) - 1]);
          $out = implode('/', $outs) . '/';
        }
        if ($page > 1) {
          if (substr($out, -1) != '/') {
            $out .= '/';
          }
          $out .=  str_replace('{$page}', $page, $page_text);
        }
        $out = "\"$out\"";
      }
      return $out;
    }

  }

?>

thank you ever so much kkeith. cheers

i guess i should of looked at your code and problem more. the reason the results are not displaying is that when the page is redirected the post data is gone meaning that there is no chooser variable. i suggest passing this info with the url. if i need to do this i will just let me know. sorry it took me so long

hi kkeith. time is not a problem, just grateful for your help & experience. if you could amend with url would be grateful. what url do you need. page2 should go to:

http://localhost/public_html/cp/data.php?page=2

and so on. if you need any further info, please let me know. cannot upload to server until i sort this problem out. thanks very much.

can you post the form that submits the chooser variable? i have to make a few changes to it and code and i think the problem will be solved

here u go kkeith.

<!-- This defines a new form -->
<form action="data.php" method="post">

<!-- This creates the dropdown in html -->
<select name="chooser">

<option value="1">List #1</option>
<option value="2">List #2</option>
<option value="3">List #3</option>

</select>

<!-- Create a button -->
<input type="submit" value="Select" name="select">

</form>

thank you

here is the form code:

<form action="data.php" method="get">
	<select name="chooser">
		<option value="1">List 1</option>
		<option value="2">List 2</option>
		<option value="3">List 3</option>
	</select>
	<input type="submit" value="Select" name="select">
</form>

here is the php code:

<?php

function ShowMyFiles() {

 

// vars global configuration

global $dbConn, $theme_path;

 

// vars messages

global $msg;

// vars template

global $error_msg, $status, $files, $owner, $test, $paginated;

 

if ($err) {

$error_msg = 'Custom error message';

}

 

if(!isset($_GET['page'])){

$page = 1;

} else {

$page = $_GET['page'];

}

  

// if something has been chosen


if (isset($_GET['chooser'])) {

// get the chosen value

$chooser = $_GET['chooser'];

 

// Define the number of results per page

$max_results = 10;

 

// Figure out the limit for the query based

// on the current page number.

$from = (($page * $max_results) - $max_results);

 

// get file listing

// if everything successful create query

// this selects all rows where the type is the one you chose in the dropdown

// * means that it will select all columns, ie name and type as i said above

 

$sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";

$result = $dbConn->Execute($sql) or die(mysql_error());

 

 

// Figure out the total number of results in DB:

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM idx_reslink WHERE category_id='$chooser'"),0);

 

 

// Figure out the total number of pages. Always round up using ceil()

$lastpage = ceil($total_results / $max_results);

 

 

 

global $paginated;

$paginated .= "<center>Select a Page<br />";

 

if ($page == 1) {

$paginated .= " FIRST PREV ";

} else {

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=1'>FIRST</a> ";

$prevpage = $page-1;

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$prevpage'>PREV</a> ";

}

$paginated .= " ( Page $page of $lastpage ) ";

 

if ($page == $lastpage) {

$paginated .= " NEXT LAST ";

} else {

$nextpage = $page+1;

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$nextpage'>NEXT</a> ";

$paginated .= " <a href='{$_SERVER['PHP_SELF']}?chooser=" . $chooser . "&page=$lastpage'>LAST</a> ";

}

 

$test = '';

for($i = 0;$i < $result->RecordCount(); $i++){

$file = $result->Fields("title");

$description = $result->Fields("description");

$date = $result->Fields("date");

 

$test .= '<table width="100%%" border="0">

<tr>

<td></td>

</tr>

</table>

 

<table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">

<tr class="tbl_caption_mem">

<td width="12%"><strong>Title</strong></td>

<td width="73%"><strong>Description</strong></td>

<td width="15%"><strong>Date Added</strong></td>

</tr>

<tr class="tbl_caption_mem">

<td valign="top">'.$file.'</td>

<td valign="top">'.$description.'</td>

<td valign="top">'.$date.'</td>

</tr>

</table> <br />';

 

$result->movenext();

}

}

$files = $test;

DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");

}

 

/*===================================================

  main

  ===================================================*/

 

include "../application.php";

 

RunPreFilter(__FILE__);

 

ShowMyFiles();

 

RunPostFilter(__FILE__);

 

?>

i cannot test this so i don't know if i made any stupid syntax errors. just let me know if there are any and i will fix them. i think the code will work but i am not for sure. i will keep trying until the problem is solved.

dosen't display anything now kkeith. just 'there are no records'. thanks

what was the url after you submitted the form?

kkeith. sorted now. wasn't posting the data to $nextpage. thank you evero so much for all your hard work and effort. very much appreciated. cheers

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.