配置文件a.conf
# 全局变量
bgColor = #FF3399
[mycolor]
display =true
bgColor = #FFFCCC
[yourcolor]
bgColor = #224466
if_smarty_from.html文件
<body>
<formaction="../../if_smarty.php" method="post">
请输入学号进行查询:<input type="text"name="text" />
请选择查询方式:<input type="radio"value="left" name="dqfs" />left
<inputtype="radio" value="center" name="dqfs"/>center
<inputtype="radio" value="right" name="dqfs" />right
<inputtype="submit" value="提交"/>
</form>
</body>
If_smarty_form.tpl文件
<{config_loadfile="a.conf" section="mycolor"}>
<!DOCTYPE htmlPUBLIC "-//W3C//DTDXHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>无标题文档</title>
</head>
<bodybgcolor=<{#bgColor#}>>
<{if#display#}>
<{if$dq=='left'}>
<divstyle=" float:left;">
<table>
<tr>
<{sectionname=stu loop=$text}>
<td><{$text[stu]}></td>
<{/section}>
<tr></table>
</div>
<{elseif$dq=='right'}><span style="float:right;"><table>
<tr>
<{sectionname=stu loop=$text}>
<td><{$text[stu]}></td>
<{/section}>
<tr></table></span>
<{else}><center><table>
<tr>
<{sectionname=stu loop=$text}>
<td><{$text[stu]}></td>
<{/section}>
<tr></table></center>
<{/if}>
<{else}>显示功能没有打开,请打开配置文件,将display=false改为true<{/if}>
</body>
</html>
If_smarty.php文件
<?php
include'libs/Smarty.class.php';
$link=mysql_connect('localhost','root','');
mysql_select_db('ecshop_text');
$q="select *from brand where id='".trim($_POST['text'])."'";
$result =mysql_query($q);
$row =mysql_fetch_row($result);
$smarty=newSmarty();
$smarty->config_dir='demo/configs';
$smarty->reInitSmarty("demo/templates","demo/templates_c");
$smarty->assign("text",$row);
$smarty->assign('dq',$_POST['dqfs']);
$smarty->display("if_smarty_form.tpl");
?>