<?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'=>'&Icirc;&Ograve;&micro;&Auml;&micro;&Uacute;&Ograve;&raquo;&cedil;&ouml;&Auml;&pound;°&aring;'));
//$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();?>

解决方案 »

  1.   

    netvt(网路维他) ,有空在指点一下:
    $tpl->assign(STAFFNAME,$row[2]);
    $tpl->parse('myrows','.arow');
    宏变量的大小写问题,加引号问题,好象也不是必定回出错?
      

  2.   

    模板宏变量,最好是和模板文件内的一致,时间长了,你也许发现对于大小写方面引起错误,有时很难查找出来.前一段时间曾用过fastTemplate..现在改为PHPLIB的Template了,
    至于哪一个更好,还有待验证.据www.phpe.net上的测试数据,PHPLIB的好象好一点.你可以去看一看.我也是在错误中成长的:)
    共同进步!