您的位置:首页 > 其它

think3.2 单页内容

2015-11-23 00:18 543 查看
配置

/tp-ceshi/Application/Common/Conf/config.php

<?php

return array(

    //'配置项'=>'配置值'

    'DEFAULT_MODULE'        =>  'Admin',  // 默认模块

    'DEFAULT_CONTROLLER'    =>  'Index', // 默认控制器名称

    'DEFAULT_ACTION'        =>  'index', // 默认操作名称

    'DB_TYPE'               =>  'mysqli',     // 数据库类型

    'DB_HOST'               =>  'localhost', // 服务器地址

    'DB_NAME'               =>  'thinkphp0421',          // 数据库名

    'DB_USER'               =>  'root',      // 用户名

    'DB_PWD'                =>  'root',          // 密码

    'DB_PORT'               =>  '3306',        // 端口

   

    'DB_FIELDS_CACHE'       =>  true,        // 启用字段缓存

    'URL_MODEL'             =>   0,// 0 普通模式, 1, pathinfo模式 ,2. rewirte模式  3. 兼容模式

    'SHOW_PAGE_TRACE'        =>    true,  //打开Trace Page 调试页

//    'TMPL_ENGINE_TYPE'      =>'smarty'

  

);

------------------***--------------------------**---------------<br>

1. 数据库

/*

Navicat MySQL Data Transfer

Source Server         : root

Source Server Version : 50540

Source Host           : localhost:3306

Source Database       : thinkphp0421

Target Server Type    : MYSQL

Target Server Version : 50540

File Encoding         : 65001

Date: 2015-11-22 05:06:33

*/

SET FOREIGN_KEY_CHECKS=0;

-- ----------------------------

-- Table structure for goods

-- ----------------------------

DROP TABLE IF EXISTS `goods`;

CREATE TABLE `goods` (

  `goods_id` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',

  `goods_name` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品名称',

  `goods_price` decimal(10,2) NOT NULL DEFAULT '0.00' COMMENT '价格',

  `goods_number` int(11) NOT NULL DEFAULT '100' COMMENT '数量',

  `goods_introduce` text COLLATE utf8_unicode_ci COMMENT '详细介绍',

  `goods_big_img` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品图片',

  `goods_small_img` varchar(128) COLLATE utf8_unicode_ci NOT NULL DEFAULT '' COMMENT '商品小图',

  `goods_create_time` int(11) NOT NULL DEFAULT '0' COMMENT '添加时间',

  `goods_last_time` int(11) NOT NULL DEFAULT '0',

  PRIMARY KEY (`goods_id`)

) ENGINE=InnoDB AUTO_INCREMENT=56 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci COMMENT='商品表';

-- ----------------------------

-- Records of goods

-- ----------------------------

INSERT INTO `goods` VALUES ('1', '1', '0.00', '100', '1', '1', '1', '0', '0');

INSERT INTO `goods` VALUES ('2', '2', '0.00', '2', '1', '1', '1', '0', '0');

***---------------**-------<br>

-

2.  /tp-ceshi/Application/Admin/View/Goods/index.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>

<title>ECSHOP 管理中心 - 商品管理 </title>

<meta name="robots" content="noindex, nofollow">

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<link href="__CSS__/general.css" rel="stylesheet" type="text/css" />

<link href="__CSS__/main.css" rel="stylesheet" type="text/css" />

</head>

<body>

<h1>

    <span class="action-span"><a href="brandAdd.html">添加货品</a></span>

    <span class="action-span1"><a href="#">ECSHOP 管理中心</a></span>

    <span id="search_id" class="action-span1"> - 商品 </span>

    <div style="clear:both"></div>

</h1>

<div class="form-div">

    <form action="" name="searchForm">

    <img src="__IMG__/icon_search.gif" width="26" height="22" border="0" alt="search" />

    <input type="text" name="brand_name" size="15" />

    <input type="submit" value=" 搜索 " class="button" />

    </form>

</div>

<form method="post" action="" name="listForm">

    <div class="list-div" id="listDiv">

        <table cellpadding="3" cellspacing="1">

            <tr>

                <th>商品名称</th>

                <th>商品价格</th>

                <th>商品数量</th>

                <th>添加时间</th>

                <th>更新时间</th>

                <th>操作</th>

            </tr>

            <volist name="rows" id="row" empty="没有记录">

                <tr>

                    <td class="first-cell">

                        <span style="float:right">{$row.goods_name}</span>

                    </td>

                    <td align="center">{$row.goods_price}</td>

                    <td align="center">{$row.goods_number}</td>

                    <td align="center">{:date('Y-m-d H:i:s',$row['inputTime'])}</td>

                    <td align="center">2013-12-17 14:51</td>

                    <td align="center">

                    <a href="#" title="编辑">编辑</a> |

                    <a href="#" title="编辑">移除</a>

                    </td>

                </tr>

            </volist>

            <tr>

                <td align="right" nowrap="true" colspan="6">

                    <div id="turn-page">

                        总计 <span id="totalRecords">11</span>

                        个记录分为 <span id="totalPages">1</span>

                        页当前第 <span id="pageCurrent">1</span>

                        页,每页 <input type='text' size='3' id='pageSize' value="15" />

                        <span id="page-link">

                            <a href="#">第一页</a>

                            <a href="#">上一页</a>

                            <a href="#">下一页</a>

                            <a href="#">最末页</a>

                            <select id="gotoPage">

                                <option value='1'>1</option>

                            </select>

                        </span>

                    </div>

                </td>

            </tr>

        </table>

    </div>

</form>

<div id="footer">

共执行 3 个查询,用时 0.021251 秒,Gzip 已禁用,内存占用 2.194 MB<br />

版权所有 © 2005-2012 上海商派网络科技有限公司,并保留所有权利。</div>

</body>

</html>

----**----------------------***---------<br>

3.

/tp-ceshi/Application/Admin/Model/GoodsModel.class.php

<?php

namespace Admin\Controller;

use Think\Controller;

class GoodsController extends Controller{

    
public function index(){

/*$goodsModel->select();  //查询
$goodsModel->add();  //添加
$goodsModel->save(); //修改
$goodsModel->delete();  //删除 */

$goodsModel = D(Goods);

$goodsModel->where('goods_id=2');

 

$rows = $goodsModel->select();  //查询
$this->assign('rows',$rows);
$this->display();
 

}
    

------------*-----------------------------*--------<br>

4.  /tp-ceshi/Application/Admin/Model/GoodsModel.class.php

<?php

/**

 * Created by PhpStorm.

 * User: Administrator

 * Date: 14-6-23

 * Time: 下午2:08

 */

namespace Admin\Model;

use Think\Model;

class GoodsModel extends Model{

    

}

-------------------**------------------------**-----------<br>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: