zoukankan      html  css  js  c++  java
  • SMARTY的简单实例写法

    访问页面main.php(后台页面)

    <?php
    include("../init.inc.php"); //引入入口文件
    include("../DBDA.php");
    $db = new DBDA();
    $sql = "select * from nation";
    $arr = $db->Query($sql);
    $smarty->assign("arr",$arr);
    $smarty->display("main.html");

    前台显示页面main.html

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    </head>
    <body>
    <h1>民族信息</h1>
    <table width="100%" border="1" cellpadding="0" cellspacing="0">
        <tr>
            <td>代号</td>
            <td>名称</td>
            <td>操作</td>
        </tr>
        
        <{foreach $arr as $v}>
        <tr>
            <td><{$v[0]}></td>
            <td><{$v[1]}></td>
            <td><a href="del.php?code=<{$v[0]}>">删除</a><a href="update.php?code=<{$v[0]}>">修改</a></td>
        </tr>
        <{/foreach}>
        
    </table>
    <a href="add.php">添加数据</a>
    </body>
    </html>

    所有的处理页面跟正常的处理页面一样写就可以了,不需要加其它代码。

    主要是注意前台和后台页面的分离,然后php和html的写法,处理页面的php基本一样。

  • 相关阅读:
    LintCode "Maximum Gap"
    LintCode "Wood Cut"
    LintCode "Expression Evaluation"
    LintCode "Find Peak Element II"
    LintCode "Remove Node in Binary Search Tree"
    LintCode "Delete Digits"
    LintCode "Binary Representation"
    LeetCode "Game of Life"
    LintCode "Coins in a Line"
    LintCode "Word Break"
  • 原文地址:https://www.cnblogs.com/gaobint/p/6769485.html
Copyright © 2011-2022 走看看