ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:addons:addons_index

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
v5:addons:addons_index [2016/03/20 01:41] – [Paging & Scrolling with ADOdb Pager] mnewnhamv5:addons:addons_index [2023/05/12 19:12] (current) – [Paging & Scrolling with ADOdb Pager] move screenshot before code snippet dregad
Line 178: Line 178:
 ===== The xmlrpc library ====== ===== The xmlrpc library ======
 This addon provides an interface between the adodb recordset and the php xmlrpc library. [[v5:addons:xmlrpc|More Information]] This addon provides an interface between the adodb recordset and the php xmlrpc library. [[v5:addons:xmlrpc|More Information]]
 +-----------------------------
  
 ===== Paging & Scrolling with ADOdb Pager ===== ===== Paging & Scrolling with ADOdb Pager =====
  
-The following code creates a very simple recordset pager, where you can scroll from page to page of a recordset.+<WRAP right box> 
 +== Requires == 
 +  adodb-pager.inc.php 
 +</WRAP>  
  
-<code php> +The following code snippet creates a very simple pager like the sample one shown below, allowing you to navigate between pages of a recordset.
-include_once('../adodb.inc.php');+
  
-include_once('../adodb-pager.inc.php');+{{:v5:addons:adodb_pager_sample_output.png|Sample output from ADODB_Pager}} 
 +<WRAP clear/>
  
-session_start(); +<code php> 
-$db = NewADOConnection('mysql')+include_once 'adodb/adodb.inc.php'; 
-$db->Connect('localhost','root','','xphplens'); +include_once 'adodb/adodb-pager.inc.php';
-$sql = "select * from adoxyz ";+
  
-$pager new ADODB_Pager($db,$sql);+$db ADONewConnection('mysqli'); 
 +$db->connect('localhost''user', 'password', 'adodb');
  
-$pager->Render($rows_per_page=5);+$sql 'select * from adoxyz';
  
 +$pager = new ADODB_Pager($db, $sql);
 +$pager->render(5);
 </code> </code>
-This will create a basic record pager that looks like this: 
  
-    |<   <<   >>   >+The number of rows to display at one time is controled by the //Render($rows)// method. If you do not pass any value to Render(), the Pager will default to 10 records per page.
-   +
-  ^ID^First Name^Last Name^Date Created^ +
-  |36|Alan|Turing|Sat 06, Oct 2001|  +
-  |37|Serena|Williams|Sat 06, Oct 2001|  +
-  |38|Yat Sun|Sun|Sat 06, Oct 2001|  +
-  |39|Wai Hun|See|Sat 06, Oct 2001|  +
-  |40|Steven|Oey|Sat 06, Oct 2001| +
-  +
-  Page 8/10 +
- +
-The number of rows to display at one time is controled by the Render($rows) method. If you do not pass any value to Render(), ADODB_Pager will default to 10 records per page. +
- +
-You can control the column titles by modifying your SQL (supported by most databases):+
  
 +You can control the column titles by aliasing them in your SQL (supported by most databases):
 <code php> <code php>
 $sql = 'select id as "ID",  $sql = 'select id as "ID", 
Line 223: Line 216:
 </code> </code>
                                    
-The above code can be found in the adodb/tests/testpaging.php example included with this release, and the class ADODB_Pager in adodb/adodb-pager.inc.php. The ADODB_Pager code can be adapted by a programmer so that the text links can be replaced by images, and the dull white background be replaced with more interesting colors.+The ADODB_Pager code can be adapted by a programmer to improve the layout, e.g. replacing the text links by images, and the dull white background by more interesting colors. 
 + 
 +By default, special characters in the displayed data will be escaped to prevent execution of HTML code. If you wish to have them interpreted instead, before calling Render() you can set 
 +<code php> 
 +  $pager->htmlSpecialChars = false; 
 +</code>
  
-You can also allow display of html by setting $pager->htmlSpecialChars = false.+<WRAP important> 
 +This is a **security risk**, unescaped HTML will leave you vulnerable to Cross-site scripting (XSS) attacks. 
 +Use with caution, and only with trusted data. 
 +</WRAP>
  
-Some of the code used here was contributed by Iván Oliva and Cornel G.. 
v5/addons/addons_index.1458434516.txt.gz · Last modified: 2017/04/21 11:22 (external edit)