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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jan 30 03:29:43 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Branch point for: no_vendor_tag
Initial revision

1 <?php
2
3 /**
4 * Another example of how to build a table
5 * with some data
6 *
7 *
8 * $Id: example2.php,v 1.1 2002/09/26 00:08:06 hemna Exp $
9 *
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 $page->set_text_debug( $_GET["debug"] );
28
29 //build a <style> tag and a little bit
30 //of local css declarations to spruce up
31 //the look of the table.
32 //You can also easily add external stylesheet
33 //links. I'll show that in other examples.
34 $style = html_style();
35 $style->add( "span.foo { font-size: 1em; font-weight: bolder;}" );
36 $style->add( "td { padding-left: 5px; text-align: center;}" );
37 $style->add( "table {border: 2px solid #999999;}" );
38 $style->add( "th {background-color: #eeeeee; ".
39 "border-bottom: 2px solid #999999;}" );
40 $style->add( "caption { font-size: 14pt; font-weight: bold;}" );
41 $page->add_head_content( $style );
42
43
44 //lets add a simple link to this script
45 //and turn debugging on,
46 //then add 2 <br> tags
47 $page->add( html_a($_SERVER["PHP_SELF"]."?debug=1", "Show Debug Source"),
48 html_br(2) );
49
50
51 //build the table that will hold the data
52 $data_table = html_table("500", 0, 0);
53
54 //add a caption for the table.
55 $data_table->add( html_caption("A Caption for the table") );
56
57 //Add 1 <tr> to the table with 3 <th> tags.
58 $data_table->add_row( html_th("Column 1"), html_th("Column 2"),
59 html_th("BAR") );
60
61
62 //now demonstrate an easy way to add
63 //20 rows to a table 1 row at a time.
64 //You could easily pull the row data from
65 //a DB
66 for($x=0; $x<20; $x++) {
67 //add 1 <tr> to the table with 3 <td>'s
68 //the last <td> contains a span with a
69 //class attribute of "foo"
70 $data_table->add_row("Row #".($x+1),
71 $x*2,
72 html_span("foo", "something else"));
73 }
74
75 //add the table to the page.
76 $page->add( $data_table );
77
78
79 //this will render the entire page
80 print $page->render();
81 ?>

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