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 "$key | ";
}
echo "
";
for($i=0;$i<mysql_num_rows($res);$i++)
{
echo "";
foreach ($rs as $key=>$value)
{
echo"{$value} | ";
}
echo"
";
$rs=mysql_fetch_array($res,1);
}
echo "
";
}
}
$conn=mysql_connect("localhost","root","");mysql_select_db("test");$x=new Bind("test");$x->Cratetable();
?>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/786540/viewspace-927691/
,如需转载,请注明出处,否则将追究法律责任。