Database
  Home arrow Database arrow Page 7 - 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 - More HTML Generation


    (Page 7 of 12 )

    The fifth argument to rs2html() is a boolean that controls whether the function prints data or returns data. The default, true, means that rs2html() prints an HTML table. Passing false for this argument tells rs2html() to return the HTML table as a string instead.

    The behavior of rs2html() is also controlled by two global variables: $gSQLMaxRows and $gSQLBlockRows. The $gSQLMaxRows variable controls how many rows from one record set rs2html() prints. It defaults to 1000. The $gSQLBlockRows variable controls how many rows from one record set rs2html() prints in one table. It defaults to 20. If a record set contains more than $gSQLBlockRows rows, rs2html() splits the records into multiple tables. The first $gSQLBlockRows rows go in the first table, the next $gSQLBlockRows rows go into the next table, and so on. You can set $gSQLBlockRows to 2 to see this at work with the ice cream example:

    $rs = $conn->execute('SELECT flavor,calories,price FROM ice_cream');
    $gSQLBlockRows = 2;
    rs2html($rs);

    The following is the HTML output. Figure 2-2 shows what it looks like in a browser.

    <table COLS=3 BORDER='1' WIDTH='98%'>

    <TH>flavor</TH><TH>calories</TH><TH>price</TH>

    <TR valign=top>
         <TD>Chocolate&nbsp;</TD>
         <TD align=right>10&nbsp;</TD>
         <TD align=right>4.50&nbsp;</TD>

    </TR>  

    </TR valign=top>
         <TD>Vanilla&nbsp;</TD>
         <TD align=right>20&nbsp;</TD>
         <TD align=right>4.50&nbsp;</TD>

    </TR>

    </table>

    <table COLS=3 BORDER='1' WIDTH='98%'>

    <TH>flavor</TH><TH>calories</TH><TH>price</TH><TR valign=top>
         <TD>&quot;Heavenly&quot; Hash&nbsp;</TD>
         <TD align=right>60&nbsp;</TD>
         <TD align=right>5.95&nbsp;</TD>

    </TR

    <TR valign=top> 
         <TD>Diet Cardboard&nbsp;</TD>
         <TD align=right>0&nbsp;</TD> 
         <TD align=right>1.15&nbsp;</TD>

    </TR>

    </table>


    Figure 2-2. The rs2html() function can generate multiple tables per page.

    After putting two rows in the first table, rs2html() closes the table and starts a new one, complete with header row. The remaining two rows are put in the second table. Splitting large record sets into multiple tables can help browsers render the data quicker because a browser can’t render a table until it receives all the data in the table. It can also be helpful for users to see the header row interspersed periodically throughout a large data set so they know what each column means.

    The rs2html() function prints rows from the record set starting from the current internal pointer position in the record set. If you’ve moved the internal pointer, by calling MoveNext(), for example, you need to move it back to the beginning of the record set with MoveFirst() if you want rs2html() to print the entire record set. After rs2html() runs, it leaves the internal pointer at the end of the record set, so you also need to use MoveFirst() if you want to call rs2html() twice on the same record set:

    rs2html($rs);
    $rs->MoveFirst();
    rs2html($rs);

    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 5 hosted by Hostway
    Stay green...Green IT