<?php
header("Content-type:text/plain");
include("../includes/fasttemplate/class.FastTemplate.php3");
$tpl = new FastTemplate("../includes/fasttemplate/templates");$tpl->define(
array('mymain'=>'mymain.tpl',
'mytable'=>'mytable.tpl',
'arow'=>'arow.tpl')
);
$tpl->assign(array('title'=>'ÎҵĵÚÒ»¸öÄ£°å'));
//$tpl->fastprint(); 注释掉
$handler=mysql_connect("192.168.1.168","root","nopassword") or die('can not.');
if($handler==0)
print "can't connect to localhost!";
mysql_select_db('mydb');
$query="select sn,staffid,staffname from staff ";
$result=mysql_query($query,$handler);for($i=0;$i<mysql_num_rows($result);$i++)
{
$row=mysql_fetch_row($result);
$tpl->assign(SN,$row[0]);
$tpl->assign(STAFFID,$row[1]);//改大写
$tpl->assign(STAFFNAME,$row[2]);//改大写
$tpl->parse('myrows','.arow');
}
//$tpl->parse('MAINBODY',array('mytable','mymain'));
$tpl->parse('MAINBODY','mytable');
$tpl->parse('MAINBODY','mymain'); $tpl->FastPrint();?>
header("Content-type:text/plain");
include("../includes/fasttemplate/class.FastTemplate.php3");
$tpl = new FastTemplate("../includes/fasttemplate/templates");$tpl->define(
array('mymain'=>'mymain.tpl',
'mytable'=>'mytable.tpl',
'arow'=>'arow.tpl')
);
$tpl->assign(array('title'=>'ÎҵĵÚÒ»¸öÄ£°å'));
//$tpl->fastprint(); 注释掉
$handler=mysql_connect("192.168.1.168","root","nopassword") or die('can not.');
if($handler==0)
print "can't connect to localhost!";
mysql_select_db('mydb');
$query="select sn,staffid,staffname from staff ";
$result=mysql_query($query,$handler);for($i=0;$i<mysql_num_rows($result);$i++)
{
$row=mysql_fetch_row($result);
$tpl->assign(SN,$row[0]);
$tpl->assign(STAFFID,$row[1]);//改大写
$tpl->assign(STAFFNAME,$row[2]);//改大写
$tpl->parse('myrows','.arow');
}
//$tpl->parse('MAINBODY',array('mytable','mymain'));
$tpl->parse('MAINBODY','mytable');
$tpl->parse('MAINBODY','mymain'); $tpl->FastPrint();?>
$tpl->assign(STAFFNAME,$row[2]);
$tpl->parse('myrows','.arow');
宏变量的大小写问题,加引号问题,好象也不是必定回出错?
至于哪一个更好,还有待验证.据www.phpe.net上的测试数据,PHPLIB的好象好一点.你可以去看一看.我也是在错误中成长的:)
共同进步!