• 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>

  • 相关阅读:
    kuangbin_ShortPath P (HDU 4725)
    kuangbin_ShortPath O (LightOJ 1074)
    方法的定义格式
    A Better Finder Rename 9.40 Key
    [iOS] 初探 iOS8 中的 Size Class
    iOS 后台执行
    iOS7 毛玻璃效果
    PhpStorm8 注册码
    [教程] 【终极开关机加速!!】手把手教你加速Mac的开关机速度。(经验证适用10.10!)
    iOS 取应用版本
  • 原文地址:https://www.cnblogs.com/apolloren/p/8903222.html
Copyright © 2020-2023  润新知