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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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 / 40
    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

    - Manage Projects with SQL Server Management S...
    - Query Editing and Regular Expressions with S...
    - Using SQL Server Management Studio Tools
    - SQL Server Management Studio
    - Exporting a MySQL Database to Excel Using OD...
    - Controlling Databases with SQL Server 2005 D...
    - Using Recovery Models with SQL Server 2005 D...
    - Handling Database Properties for the SQL Ser...
    - Managing Permissions with the SQL Server 200...
    - SQL Server 2005 Database Engine Security
    - Administering SQL Server 2005 Database Engine
    - Building Applications with Anonymous Types
    - A Closer Look at Anonymous Types
    - Programming with Anonymous Types
    - Converting Your Excel Worksheet into a Worki...





    © 2003-2010 by Developer Shed. All rights reserved. DS Cluster 7 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek