Database
  Home arrow Database arrow Page 9 - Accessing Databases with ADODB
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DATABASE

Accessing Databases with ADODB
By: Apress Publishing
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 37
    2004-08-02

    Table of Contents:
  • Accessing Databases with ADODB
  • Connecting, Queries and Quoting
  • Introducing Record Sets
  • Retrieving Multiple Rows
  • Understanding Error Handling
  • Generating HTML
  • More HTML Generation
  • Printing
  • Splitting Data Across Multiple Pages
  • Pivot Tables
  • Caching
  • Exporting Data

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Accessing Databases with ADODB - Splitting Data Across Multiple Pages


    (Page 9 of 12 )

    The ADODB_Pager class, defined in the adodb-pager.inc.php file, provides a class that formats and displays a certain number of the rows in a record set with appropriate links to display more of the record set on other pages. You provide a database connection and a query when creating an ADODB_Pager object. The Render() method displays the results, shown in Figure 2-3.

    $pager = new ADODB_Pager($conn,"SELECT _
                  id,flavor,calories,price FROM _
                  ice_cream_big");
    $pager->Render();


    Figure 2-3.
    ADODB_Pager displays a record set with pagination links.

    The data is displayed in a table with formatting and navigation links. The leftmost link in the table goes to the first page, the second link goes to the previous page, the third link goes to the next page, and the rightmost link goes to the last page of data. The links contain a variable that controls what page is displayed, but they don’t automatically include other GET or POST variables that may have been set. By default, ADODB_Pager displays ten rows per page. You can override that by passing an argument to Render() with the number of rows per page you want. The following code generates a five-row table, shown in Figure 2-4:

    $pager = new ADODB_Pager($conn,"SELECT id,flavor, _
                             calories,price FROM ice_cream_big");
    $pager->Render(5);


    Figure 2-4.
    ADODB_Pager can display a specified number of rows from a record set.

    Internally, ADODB_Pager uses the rs2html() function to generate the HTML for the table. It overwrites the global variable $gSQLBlockRows with the number of rows per page it is displaying.

    If you put more than one pager object in a page, ADODB_Pager needs to tell them apart so the next and previous links advance the correct pager. To accomplish this, each pager object needs a unique ID. The ID is specified as the third argument to the ADODB_Pager constructor. The default is adodb. To use two pager objects in one page, specify different IDs when you create the objects. The following code creates one pager with five rows and one with two rows:

    $pager1 = new ADODB_Pager($conn,"SELECT id,flavor,calories, _
    price FROM ice_cream_big",'big');
    $pager1->Render(5);

    $pager2 = new ADODB_Pager($conn,"SELECT id,flavor,calories, _
    price FROM ice_cream", 'little');
    $pager2->Render(2);

    Figure 2-5 shows the two pager tables.


    Figure 2-5.
    ADODB_Pager can display multiple tables on a page.

    You can also include direct links to individual pages in the navigation by passing true as the fourth argument to the ADODB_Pager constructor. The following code creates a three-row table with individual page links:

    $pager = new ADODB_Pager($conn,"SELECT id,flavor, _
                     calories,price FROM ice_cream_big",'big',true);
    $pager->Render(3);

    Figure 2-6 shows the table.


    Figure 2-6.
    ADODB_Pager can display navigation links to individual pages in the record set.

    This is from Essential PHP Tools, by David Sklar (Apress, ISBN 1590592808). Check it out at your favorite bookstore today. Buy this book now.

    More Database Articles
    More By Apress Publishing


       · i want the programming code for the add delete update useing the adodb ontrols.
     

    DATABASE ARTICLES

    - Excel Reference
    - Database Programming in C# with MySQL : Usin...
    - Formatting Techniques for Data Access from E...
    - Data Access from Excel VBA
    - Generating a Multiple Table Crystal Report u...
    - ADO and the Command Object
    - On Wiring Up an ADO Data Control
    - Reading and Writing to Files on the Intranet
    - Using ADO Record to Create and Navigate Intr...
    - Using Data Access Pages to Access Data on a ...
    - Using ADO with the SQL Native Client
    - ADO`s Stream Object
    - Opening a Record Object Referencing an Open ...
    - Introducing Jasper (SQL Anywhere 10 Beta)
    - Creating a Database Project in VS 2005

     
    Application Delivery: Everything You Wanted to Know, but Didn`t Know You Needed to Ask
    A comprehensive guide to examining the topics of Wide-area Data Services and app....

     
    Best Practices: Safe and Secure Hardware Asset Recovery
    Companies increasingly must meet EPA and local requirements for the disposal of ....

     
    Managing SSL Security in Multi-Server Environments
    Read this white paper to learn how to simplify management of your organization's....

     
    Open Source Security Myths
    Open Source Software (OSS) is computer software whose source code is available t....

     
    Power and Cooling Capacity Management for Data Centers
    This paper describes the principles for achieving power and cooling capacity man....

     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT