User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,547 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,353 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1477 | Replies: 16 | Solved
Reply
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

pagination not displaying results

  #1  
Oct 17th, 2007
hi. i wonder if someone could check this script for me and tell why it isn't producing any results. here is the code:

  1.  
  2. <?php
  3. function ShowMyFiles() {
  4.  
  5. // vars global configuration
  6. global $dbConn, $theme_path;
  7.  
  8. // vars messages
  9. global $msg;
  10. // vars template
  11. global $error_msg, $status, $files, $owner, $test, $paginated;
  12.  
  13. if ($err) {
  14. $error_msg = 'Custom error message';
  15. }
  16.  
  17. if(!isset($_GET['page'])){
  18. $page = 1;
  19. } else {
  20. $page = $_GET['page'];
  21. }
  22.  
  23. // get variable after selecting something from the dropdown with name 'chooser'
  24. $select = $_POST['select'];
  25.  
  26.  
  27. // if something has been chosen
  28. if (!empty($select)) {
  29.  
  30. // get the chosen value
  31. $chooser = $_POST['chooser'];
  32.  
  33. // Define the number of results per page
  34. $max_results = 10;
  35.  
  36. // Figure out the limit for the query based
  37. // on the current page number.
  38. $from = (($page * $max_results) - $max_results);
  39.  
  40. // get file listing
  41. // if everything successful create query
  42. // this selects all rows where the type is the one you chose in the dropdown
  43. // * means that it will select all columns, ie name and type as i said above
  44.  
  45. $sql = "SELECT title, description, date FROM idx_reslink WHERE category_id='$chooser' LIMIT $from, $max_results";
  46. $result = $dbConn->Execute($sql) or die(mysql_error());
  47.  
  48.  
  49. // Figure out the total number of results in DB:
  50. $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM idx_reslink WHERE category_id='$chooser'"),0);
  51.  
  52.  
  53. // Figure out the total number of pages. Always round up using ceil()
  54. $lastpage = ceil($total_results / $max_results);
  55.  
  56.  
  57.  
  58. global $paginated;
  59. $paginated .= "<center>Select a Page<br />";
  60.  
  61. if ($page == 1) {
  62. $paginated .= " FIRST PREV ";
  63. } else {
  64. $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=1'>FIRST</a> ";
  65. $prevpage = $page-1;
  66. $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$prevpage'>PREV</a> ";
  67. }
  68. $paginated .= " ( Page $page of $lastpage ) ";
  69.  
  70. if ($page == $lastpage) {
  71. $paginated .= " NEXT LAST ";
  72. } else {
  73. $nextpage = $page+1;
  74. $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$nextpage'>NEXT</a> ";
  75. $paginated .= " <a href='{$_SERVER['PHP_SELF']}?page=$lastpage'>LAST</a> ";
  76. }
  77.  
  78. $test = '';
  79. for($i = 0;$i < $result->RecordCount(); $i++){
  80. $file = $result->Fields("title");
  81. $description = $result->Fields("description");
  82. $date = $result->Fields("date");
  83.  
  84. $test .= '<table width="100%%" border="0">
  85. <tr>
  86. <td></td>
  87. </tr>
  88. </table>
  89.  
  90. <table cellpadding="2" cellspacing="1" border="0" align="center" width="100%" class="tbl_border_mem">
  91. <tr class="tbl_caption_mem">
  92. <td width="12%"><strong>Title</strong></td>
  93. <td width="73%"><strong>Description</strong></td>
  94. <td width="15%"><strong>Date Added</strong></td>
  95. </tr>
  96. <tr class="tbl_caption_mem">
  97. <td valign="top">'.$file.'</td>
  98. <td valign="top">'.$description.'</td>
  99. <td valign="top">'.$date.'</td>
  100. </tr>
  101. </table> <br />';
  102.  
  103. $result->movenext();
  104. }
  105. }
  106. $files = $test;
  107. DisplayTemplate($theme_path . "cp/data.html", "\$files,\$paginated,\$error_msg");
  108. }
  109.  
  110. /*===================================================
  111.   main
  112.   ===================================================*/
  113.  
  114. include "../application.php";
  115.  
  116. RunPreFilter(__FILE__);
  117.  
  118. ShowMyFiles();
  119.  
  120. RunPostFilter(__FILE__);
  121.  
  122. ?>

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.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #2  
Oct 17th, 2007
can no-one offer any assistance? thanks
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #3  
Oct 17th, 2007
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
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #4  
Oct 18th, 2007
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.
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #5  
Oct 18th, 2007
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
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #6  
Oct 19th, 2007
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();

?>
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

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

  1. function MoveNext() {
  2. if ($row = mysql_fetch_assoc($this->resultset)) {
  3. $this->current_row = $row;
  4. $this->EOF = false;
  5. return true;
  6. }
  7. else {
  8. $this->EOF = true;
  9. return false;
  10. }
  11. }]

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
Reply With Quote  
Join Date: Jun 2007
Location: Valley Center, Kansas
Posts: 643
Reputation: kkeith29 is on a distinguished road 
Rep Power: 3
Solved Threads: 72
kkeith29's Avatar
kkeith29 kkeith29 is online now Online
Practically a Master Poster

Re: pagination not displaying results

  #8  
Oct 19th, 2007
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.
Reply With Quote  
Join Date: Jul 2005
Posts: 20
Reputation: ploppy is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
ploppy ploppy is offline Offline
Newbie Poster

Re: pagination not displaying results

  #9  
Oct 19th, 2007
db.class.php

  1. <?
  2.  
  3. class DB_Connection {
  4. var $conn = null;
  5. var $debug = false;
  6. var $num_query = 0;
  7. var $error_msg = "";
  8. var $affected_rows = 0;
  9.  
  10. function DB_Connection($host, $username, $pwd, $db) {
  11. $this->Connect($host, $username, $pwd, $db);
  12. }
  13.  
  14. function Connect($host, $username, $pwd, $db) {
  15. global $db_use_persistent;
  16. if ($db_use_persistent) {
  17. $this->conn = mysql_pconnect($host, $username, $pwd);
  18. }
  19. else {
  20. $this->conn = mysql_connect($host, $username, $pwd);
  21. }
  22. mysql_select_db($db, $this->conn);
  23. }
  24.  
  25. function Execute($query) {
  26. $query = trim($query);
  27. $this->num_query++;
  28. if ($this->debug) {
  29. static $mysql_query_number;
  30. static $mysql_query_time;
  31. $mysql_query_number++;
  32. $time_start = (float) array_sum(explode(' ', microtime()));
  33. }
  34. $result = @mysql_query($query, $this->conn);
  35. if ($this->debug) {
  36. $time_end = (float) array_sum(explode(' ', microtime()));
  37. $time = $time_end - $time_start;
  38. $time = sprintf("%01.4f", $time);
  39. $mysql_query_time += $time;
  40. $mysql_query_time = sprintf("%01.3f", $mysql_query_time);
  41. if ($time > 1) {
  42. $time = "<b>$time [slow query]</b>";
  43. }
  44. if (preg_match('/^select/i', $query)) {
  45. $num_rows = @mysql_num_rows($result);
  46. 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>";
  47. }
  48. else {
  49. 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>";
  50. }
  51. if (mysql_error()) {
  52. 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>";
  53. }
  54. }
  55. $this->error_msg = mysql_error();
  56. if ($this->error_msg) {
  57. return false;
  58. }
  59. else {
  60. if (preg_match("/^update|insert|delete/msi", $query)) {
  61. $this->affected_rows = @mysql_affected_rows($this->conn);
  62. return new DB_Resultset_empty();
  63. }
  64. else {
  65. return new DB_Resultset($result, $query);
  66. }
  67. }
  68. }
  69.  
  70. function PageExecute($query, $pg_which, $pg_size) {
  71. if (!$pg_which) {
  72. $pg_which = 1;
  73. }
  74. $query_total = $query;
  75. if (!preg_match('/group by/msi', $query_total)) {
  76. $query_total = preg_replace("|select(.*?)from|ms", "select count(*) as c from", $query_total);
  77. }
  78. $result = $this->Execute($query_total);
  79. if (preg_match('/group by/msi', $query_total)) {
  80. $num_rows = $result->RecordCount();
  81. }
  82. else {
  83. $num_rows = ($result->Fields('c')) ? $result->Fields('c') : 0;
  84. }
  85. $start = ($pg_which - 1) * $pg_size;
  86. $query = $query . " limit $start, $pg_size";
  87. $result->Close();
  88. $result = $this->Execute($query);
  89. $result->num_rows = $num_rows;
  90. return $result;
  91. }
  92.  
  93. function InsertID() {
  94. return @mysql_insert_id($this->conn);
  95. }
  96.  
  97. function Close() {
  98. return true;
  99. }
  100.  
  101. function FetchArray($query) {
  102. $result = $this->Execute($query);
  103. $arr = array ();
  104. while ($row = $result->FetchRow()) {
  105. $arr[] = $row;
  106. }
  107. $result->Close();
  108. return $arr;
  109. }
  110.  
  111. function FetchOne($query) {
  112. $result = $this->Execute($query . ' limit 1');
  113. $row = $result->FetchRow();
  114. $result->Close();
  115. return $row;
  116. }
  117.  
  118. function Lookup($field, $table, $where) {
  119. $result = $this->Execute("select $field from $table where $where limit 1");
  120. $value = $result->Fields($field);
  121. $result->Close();
  122. return $value;
  123. }
  124.  
  125. function CountQuery() {
  126. return $this->num_query;
  127. }
  128.  
  129. function ErrorMsg() {
  130. return $this->error_msg;
  131. }
  132.  
  133. function AffectedRows() {
  134. return $this->affected_rows;
  135. }
  136. }
  137.  
  138. class DB_Resultset {
  139. var $resultset = null;
  140. var $num_rows = null;
  141. var $num_field = null;
  142. var $current_row = null;
  143. var $EOF = true;
  144. var $query = null;
  145.  
  146. function DB_Resultset(&$resultset, $query = '') {
  147. $this->resultset = $resultset;
  148. $this->query = $query;
  149. if (preg_match('/^select|show|describe|explain/msi', $query)) {
  150. $this->MoveNext();
  151. }
  152. }
  153.  
  154. function RecordCount() {
  155. if (is_null($this->num_rows)) {
  156. $this->num_rows = @mysql_num_rows($this->resultset);
  157. }
  158. return $this->num_rows;
  159. }
  160.  
  161. function FieldCount() {
  162. if (is_null($this->num_field)) {
  163. $this->num_field = mysql_num_fields($this->resultset);
  164. }
  165. return $this->num_field;
  166. }
  167.  
  168. function FetchField($offset) {
  169. $field = mysql_fetch_field($this->resultset, $offset);
  170. $field->max_length = mysql_field_len($this->resultset, $offset);
  171. return $field;
  172. }
  173.  
  174. function MetaType($field_type) {
  175. switch($field_type) {
  176. case preg_match('/char/i', $field_type):
  177. return 'C';
  178. case preg_match('/int|float|double/i', $field_type):
  179. return 'I';
  180. case preg_match('/text/i', $field_type):
  181. return 'X';
  182. case preg_match('/blob/', $field_type):
  183. return 'B';
  184. default:
  185. return '';
  186. }
  187. }
  188.  
  189. function Move($offset) {
  190. if (@mysql_data_seek($this->resultset, $offset)) {
  191. return $this->MoveNext();
  192. }
  193. else {
  194. return false;
  195. }
  196. }
  197.  
  198. function MoveFirst() {
  199. return $this->Move(0);
  200. }
  201.  
  202. function MoveLast() {
  203. return $this->Move($this->num_rows - 1);
  204. }
  205.  
  206. function MoveNext() {
  207. if ($row = mysql_fetch_assoc($this->resultset)) {
  208. $this->current_row = $row;
  209. $this->EOF = false;
  210. return true;
  211. }
  212. else {
  213. $this->EOF = true;
  214. return false;
  215. }
  216. }
  217.  
  218. function Fields($name) {
  219. return $this->current_row[$name];
  220. }
  221.  
  222. function FetchRow() {
  223. if (!$this->EOF) {
  224. $row = $this->current_row;
  225. $this->MoveNext();
  226. return $row;
  227. }
  228. else {
  229. return false;
  230. }
  231. }
  232.  
  233. function Close() {
  234. if ($this->resultset) {
  235. mysql_free_result($this->resultset);
  236. }
  237. }
  238. }
  239.  
  240. class DB_Resultset_empty {
  241. var $resultset = null;
  242. var $num_rows = null;
  243. var $num_field = null;
  244. var $current_row = null;
  245. var $EOF = true;
  246. var $query = null;
  247.  
  248. function DB_Resultset() {
  249. return true;
  250. }
  251.  
  252. function RecordCount() {
  253. return 0;
  254. }
  255.  
  256. function FieldCount() {
  257. return 0;
  258. }
  259.  
  260. function FetchField($offset) {
  261. return false;
  262. }
  263.  
  264. function MetaType($field_type) {
  265. return false;
  266. }
  267.  
  268. function Move($offset) {
  269. return false;
  270. }
  271.  
  272. function MoveFirst() {
  273. return false;
  274. }
  275.  
  276. function MoveLast() {
  277. return false;
  278. }
  279.  
  280. function MoveNext() {
  281. return false;
  282. }
  283.  
  284. function Fields($name) {
  285. return false;
  286. }
  287.  
  288. function FetchRow() {
  289. return false;
  290. }
  291.  
  292. function Close() {
  293. return true;
  294. }
  295. }
  296.