Zend - The PHP Company




HTML

Add Code


tables.php - part of the html.php library  

Type: code fragment
Added by: homechicken
Entered: 21/03/2000
Last modified: 08/12/1999
Rating: - (fewer than 3 votes)
Views: 7547
Ease the pain of escaping quotes and clean up your php code, use tables.php. Made to go with html.php, lists.php, and forms.php, but they're really only groups of functions.


<?php
    
/* tables.php3
     *
     * functions to create html tables
     *
     * Refer HTML questions to http://www.w3.org/TR/REC-html40/
     */

    /* let other includes know we're here.. */
    
define("USING_TABLES""Yup");

    
/* begin function declaration */

    
function table($border=0$width=""$spacing=""$padding=""$args="") {
        
$temp "n<TABLE border=$border";
        if(
$width != "")
            
$temp .= " width="$width"";
        if(
$spacing != "")
            
$temp .= " cellspacing=$spacing";
        if(
$padding != "")
            
$temp .= " cellpadding=$padding";
        if(
$args != "")
            
$temp .= $args";
        
$temp .= ">n";
        print(
$temp);
    }

    function 
tr($args="") {
        
$temp "n<TR";
        if(
$args != "")
            
$temp .= $args";
        
$temp .= ">n";
        print(
$temp);
        
/* possible tr $args: id, class, lang, title, style, align, char, charoff, valign, intrinsic events */
    
}

    function 
td($args="") {
        
$temp "n<TD";
        if(
$args != "")
            
$temp .= $args";
        
$temp .= ">";
        print(
$temp);
        
/* possible $args: id, class, lang, title, style, bgcolor, align, char, charoff, valign, rowspan, colspan, etc */
    
}

    function 
table_close() {
        print(
"n</TABLE>n");
    }
?>    



Usage Example


<?
include("html.php");
include(
"tables.php");
doctype_transitional();
html();
head();
title("Title goes here");
head_close();
body();
center();
table(0"95%"015);
tr("valign=top");
td();
p();
print(
"Left column, first paragraph");
p();
print(
"Left column, second paragraph");
td();
p();
print(
"Right column, first paragraph");
p();
print(
"Right column, second paragraph");
table_close();
center_close();
body_close();
?>


Rate This Script





Search



This Category All Categories