两个 php 类:table 和 htmltable
/*
Code Revised from
Sam's Teach Yourself Php, Mysql and Apache in 24 Hours
(Sams Teach Yourself S.) (Paperback)
by Julie C. Meloni
# Paperback: 616 pages
# Publisher: Sams (1 Jan 2004)
# Language English
# ISBN: 0672326205
*/testing objectsheaders = $headers;
$this->cols = count ( $headers );
}
function addRow( $row ){
if ( count ($row) != $this->cols )
return false;
array_push($this->table_array, $row);
return true;
}
function addRowAssocArray( $row_assoc ) {
if ( count ($row_assoc) != $this->cols )
return false;
$row = array();
foreach ( $this->headers as $header ) {
if ( ! isset( $row_assoc[$header] ))
$row_assoc[$header] = " ";
$row[] = $row_assoc[$header];
}
array_push($this->table_array, $row) ;
}
function output() {
print "";
foreach ( $this->headers as $header )
print "$header ";
print "\n";
foreach ( $this->table_array as $y ) {
foreach ( $y as $xcell )
print "$xcell ";
print "\n";
}
print "";
}
}
class HTMLTable extends Table{
var $bgcolor;
var $cellpadding = "2";
function HTMLTable( $headers, $bg="#ffffff" ){
Table::Table($headers);
$this->bgcolor=$bg;
}
function setCellpadding( $padding ){
$this->cellpadding = $padding;
}
function output(){
print "";
foreach ( $this->headers as $header )
print "$header";
foreach ( $this->table_array as $row=>$cells ) {
print "";
foreach ( $cells as $cell )
print "$cell";
print "";
}
print "";
}
}
$test = new HTMLTable( array("a","b","c"), "#00FF00");
$test->setCellpadding( 7 );
$test->addRow( array(1,2,3));
$test->addRow( array(4,5,6));
$test->addRowAssocArray( array ( b=>0, a=>6, c=>3 ));
$test->output();
?>
以上就是的内容,更多相关内容请关注PHP中文网(www.php.cn)!
商品查询功能提供了一个快速查看商品的途径。商品查询分为基本查询和高级查询。基本查询:提供关键字和商品大类两种条件的查询,用户可以只填写关键字或者选择商品大类或者关键字和商品大类都填写来查询商品。高级查询:提供关键字,商品大类,商品小类,商品价格范围四种条件的查询,用户可以任意填写其中一种或几种的查询条件来查询想要了解的商品信息。商品查询功能大大的方便了用户,提高了网站的用户体验。(5)帮助系统模块
0
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号