if和.conf的使用,用if来决定在数据库中查询出的内容的内容

配置文件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");

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值