ITPub博客

首页 > 数据库 > 数据库开发技术 > 动态生成一个m行n列的表格

动态生成一个m行n列的表格

原创 数据库开发技术 作者:yeahokay 时间:2007-07-24 10:51:42 0 删除 编辑
function MakeTable($rows,$columns,$width=80,$height=22){$table='';
for (
$i=0;$i<$rows;$i
++){$table.='';
for (
$j=0;$j<$columns;$j
++){$table.='';
}
$table.='
';
}
$table.='
 
'
;
return
$table
;
}
//生成N行M列的表格echo MakeTable(n,m);[@more@]面向对象的
phpclass Bind{
public
$rows,$cells
;
public
$tabBgcolor,$trBgcolor
;
public
$table
function __construct($table
)
{
$this->table="$table";
//要绑定的表
$this->rows=""
;
$this->cells=""
;
$this->tabBgcolor="eeeeee"
;
$this->trBgcolor="white"
;
}
function
Cratetable
()
{
echo
"tabBgcolor style='font-size:12px'>";
$sql="select * from $this->table"
;
$res=mysql_query($sql) or die(mysql_error
());
$rs=mysql_fetch_array($res,1
);
echo
"
trBgcolor align=center style='font-family:Asia;font-size:16px'>";
foreach (
$rs as $key=>$value
)
{
echo
"
";
}
echo
"
";
for(
$i=0;$i<mysql_num_rows($res);$i
++)
{
echo
"
";
foreach (
$rs as $key=>$value
)
{
echo
"
";
}
echo
"
";
$rs=mysql_fetch_array($res,1
);
}
echo
"
$key
{$value}
"
;

}

}
$conn=mysql_connect("localhost","root",""
);mysql_select_db("test");$x=new Bind("test");$x->Cratetable();

?>

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/786540/viewspace-927691/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论