zoukankan      html  css  js  c++  java
  • smarty 对数据库的简单操作。

    smarty简单配置

    -------------------------------------smarty_inc.php--------------------------------------------

    <?php
    include_once("./smarty/Smarty.class.php");
    $smarty=new Smarty();
    $smarty->config_dir="smarty/Config_File.class.php";//目录变量
    $smarty->caching=false;//是否使用缓存
    $smarty->template_dir="./templates";//设置模板目录
    $smarty->compile_dir="./templates_c";//设置编译目录
    $smarty->cache_dir="./smarty_cache";//缓存文件夹
    $smarty->left_delimiter="{";
    $smarty->right_delimiter="}";
    ?>

    ----------------------------------index.php---------------------------------------------------

    <?php

    include("config.php");
    $sql=mysql_query("select * from xinxi order by id desc");
    while($row=mysql_fetch_array($sql)){
    $arrdata[]=$row;
    }
    $smarty->assign("xx",$arrdata);
    $smarty->display("index.htm");
    ?>

    -----------------------------------index.htm   模板文件 主要操作 如何应用section循环二维数组--------------------------------------------

    <?php include("config.php");?>
    <html

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    </head>

    <hr />
    <a href="">首页</a>|<a href="">流言</a>|
    <hr />
    <body>

    <form action="" method="post" name="form2">
    <table bgcolor="#FFFFCC" width="800"  align="left" cellpadding="0" cellspacing="1">
    <tr >
    <tr>
    <td align="center" width="50" height="20">标题
    </td>
    <td align="center" width="300" height="20">内容
    </td>
    <td align="center" width="100" height="20">留言时间
    </td>
    </tr>
    {section name=list loop=$xx}                         //主要显示代码
    <tr>
    <td align="center" width="50">
    <input name="del[]" type="checkbox" value="" />

    </td>
    <td align="center" width="50" height="20">{$xx[list].title}
    </td>
    <td align="left" width="300" height="20">{$xx[list].content}
    </td>
    <td align="center" width="100" height="20">{$xx[list].createtime}
    </td>
    </tr>
    {/section}
    </tr>
     <tr>
                              
            <td width="6">
            </td>
                 <td width="200" >
           
           </td>
      </tr>
    </table>
    </form>
    </body>
    </html>

  • 相关阅读:
    http请求头和响应头详细解释
    http协议POST请求头content-type主要的四种取值
    什么是精准测试
    测试管理(管事篇)
    有赞全链路压测方案设计与实施详解
    饿了么全链路压测平台的实现与原理
    京东全链路压测军演系统(ForceBot)架构解密
    java Apache common-io 讲解
    CentOS 7.0 安装go 1.3.1
    异常
  • 原文地址:https://www.cnblogs.com/apolloren/p/8903222.html
Copyright © 2011-2022 走看看