/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/examples/example2.php
ViewVC logotype

Annotation of /nfo/php/libs/com.newsblob.phphtmllib/examples/example2.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations)
Thu May 6 16:27:17 2004 UTC (20 years, 2 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
 updated all to v2.4.1 - Apr 01, 2004

1 jonen 1.1 <?php
2    
3     /**
4     * Another example of how to build a table
5     * with some data
6     *
7     *
8 jonen 1.3 * $Id: example2.php,v 1.2 2003/07/28 16:47:42 hemna Exp $
9 jonen 1.1 *
10     * @author Walter A. Boring IV <waboring@buildabetterweb.com>
11     * @package phpHtmlLib
12     * @subpackage examples
13     * @version 2.0.0
14     *
15     */
16    
17     /**
18     * Include the phphtmllib libraries
19     */
20     include_once("includes.inc");
21    
22    
23     //create the page object
24     $page = new HTMLPageClass("phpHtmlLib Example 2 - Table example script",
25     XHTML_TRANSITIONAL);
26    
27 jonen 1.3 if (isset($_GET['debug'])) {
28     $page->set_text_debug( TRUE );
29     }
30    
31 jonen 1.1
32     //build a <style> tag and a little bit
33     //of local css declarations to spruce up
34     //the look of the table.
35     //You can also easily add external stylesheet
36     //links. I'll show that in other examples.
37     $style = html_style();
38     $style->add( "span.foo { font-size: 1em; font-weight: bolder;}" );
39     $style->add( "td { padding-left: 5px; text-align: center;}" );
40     $style->add( "table {border: 2px solid #999999;}" );
41     $style->add( "th {background-color: #eeeeee; ".
42     "border-bottom: 2px solid #999999;}" );
43     $style->add( "caption { font-size: 14pt; font-weight: bold;}" );
44     $page->add_head_content( $style );
45    
46    
47     //lets add a simple link to this script
48     //and turn debugging on,
49     //then add 2 <br> tags
50     $page->add( html_a($_SERVER["PHP_SELF"]."?debug=1", "Show Debug Source"),
51     html_br(2) );
52    
53    
54     //build the table that will hold the data
55     $data_table = html_table("500", 0, 0);
56    
57     //add a caption for the table.
58     $data_table->add( html_caption("A Caption for the table") );
59    
60     //Add 1 <tr> to the table with 3 <th> tags.
61     $data_table->add_row( html_th("Column 1"), html_th("Column 2"),
62     html_th("BAR") );
63    
64    
65     //now demonstrate an easy way to add
66     //20 rows to a table 1 row at a time.
67     //You could easily pull the row data from
68     //a DB
69     for($x=0; $x<20; $x++) {
70     //add 1 <tr> to the table with 3 <td>'s
71     //the last <td> contains a span with a
72     //class attribute of "foo"
73     $data_table->add_row("Row #".($x+1),
74     $x*2,
75     html_span("foo", "something else"));
76     }
77    
78     //add the table to the page.
79     $page->add( $data_table );
80    
81    
82     //this will render the entire page
83     print $page->render();
84     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed