内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

ThinkPHP框架如何實(shí)現(xiàn)用戶信息查詢更新及刪除功能-創(chuàng)新互聯(lián)

這篇文章給大家分享的是有關(guān)ThinkPHP框架如何實(shí)現(xiàn)用戶信息查詢更新及刪除功能的內(nèi)容。小編覺(jué)得挺實(shí)用的,因此分享給大家做個(gè)參考,一起跟隨小編過(guò)來(lái)看看吧。

創(chuàng)新互聯(lián)建站主打移動(dòng)網(wǎng)站、成都做網(wǎng)站、網(wǎng)站建設(shè)、外貿(mào)營(yíng)銷網(wǎng)站建設(shè)、網(wǎng)站改版、網(wǎng)絡(luò)推廣、網(wǎng)站維護(hù)、域名與空間、等互聯(lián)網(wǎng)信息服務(wù),為各行業(yè)提供服務(wù)。在技術(shù)實(shí)力的保障下,我們?yōu)榭蛻舫兄Z穩(wěn)定,放心的服務(wù),根據(jù)網(wǎng)站的內(nèi)容與功能再?zèng)Q定采用什么樣的設(shè)計(jì)。最后,要實(shí)現(xiàn)符合網(wǎng)站需求的內(nèi)容、功能與設(shè)計(jì),我們還會(huì)規(guī)劃穩(wěn)定安全的技術(shù)方案做保障。

具體如下:

一 代碼

1、配置文件

<?php
return array(
  'APP_DEBUG' => false,    // 關(guān)閉調(diào)試模式
  'DB_TYPE'=> 'mysql',    // 數(shù)據(jù)庫(kù)類型
  'DB_HOST'=> 'localhost',   // 數(shù)據(jù)庫(kù)服務(wù)器地址
  'DB_NAME'=>'db_database30',     // 數(shù)據(jù)庫(kù)名稱
  'DB_USER'=>'root',      // 數(shù)據(jù)庫(kù)用戶名
  'DB_PWD'=>'root',        // 數(shù)據(jù)庫(kù)密碼
  'DB_PORT'=>'3306',      // 數(shù)據(jù)庫(kù)端口
  'DB_PREFIX'=>'think_',    // 數(shù)據(jù)表前綴
);
?>

2、入口文件

<?php
define('THINK_PATH', '../ThinkPHP');    //定義ThinkPHP框架路徑(相對(duì)于入口文件)
define('APP_NAME', 'App');       //定義項(xiàng)目名稱
define('APP_PATH', './App');        //定義項(xiàng)目路徑
require(THINK_PATH."/ThinkPHP.php");  //加載框架入口文件
App::run();               //實(shí)例化一個(gè)網(wǎng)站應(yīng)用實(shí)例
?>

3、控制器文件

<?php
header("Content-Type:text/html; charset=utf-8");  //設(shè)置頁(yè)面編碼格式
class IndexAction extends Action{
  public function index(){
    $db = M('User');              // 實(shí)例化模型類,參數(shù)數(shù)據(jù)表名稱,不包含前綴
    $select = $db->order('id desc')->limit(10)->select();
    $this->assign('select',$select);       // 模板變量賦值
    $this->display();              // 指定模板頁(yè)
  }
  public function update(){
    $db = M('User');              // 實(shí)例化模型類,參數(shù)數(shù)據(jù)表名稱,不包含前綴
    $select = $db->where('id='.$_GET['id'])->select();
    $this->assign('select',$select);       // 模板變量賦值
    $this->display(update);             // 指定模板頁(yè)
    if(isset($_POST['id'])){
      $data['user'] = $_POST['user'];       // 要修改的數(shù)據(jù)對(duì)象屬性賦值
      $data['pass'] = md5($_POST['pass']);
      $data['address'] = $_POST['address'];
      $result=$db->where('id='.$_POST['id'])->save($data);   // 根據(jù)條件保存修改的數(shù)據(jù)
      if($result){
        $this->redirect('Index/index','', 2,'數(shù)據(jù)更新成功');    //頁(yè)面重定向
      }
    }
  }
  public function delete(){
    $db = M('User');              // 實(shí)例化模型類,參數(shù)數(shù)據(jù)表名稱,不包含前綴
    $result=$db->where('id='.$_GET['id'])->delete();   // 刪除id為5的用戶數(shù)據(jù)
    if($result){
      $this->redirect('Index/index','', 2,'數(shù)據(jù)刪除成功');    //頁(yè)面重定向
    }
  }
}
?>

4、模板文件一

<!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>
<link href="__ROOT__/Public/Css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="405" border="1" cellpadding="1" cellspacing="1" bgcolor="#99CC33" bordercolor="#FFFFFF">
 <tr>
  <td colspan="4" bgcolor="#FFFFFF" class="title" align="center">用戶信息</td>
 </tr>
 <tr class="title">
  <td bgcolor="#FFFFFF" width="44">ID</td>
  <td bgcolor="#FFFFFF" width="120">名稱</td>
  <td bgcolor="#FFFFFF" width="111">地址</td>
  <td bgcolor="#FFFFFF" width="111">操作</td>
 </tr>
 <foreach name='select' item='user' >
 <tr class="content">
  <td bgcolor="#FFFFFF">{$user.id}</td>
  <td bgcolor="#FFFFFF">{$user.user}</td>
  <td bgcolor="#FFFFFF">{$user.address}</td>
  <td bgcolor="#FFFFFF"><a href="__URL__/update?id={$user.id}" rel="external nofollow" >更新</a>/<a href="__URL__/delete?id={$user.id}" rel="external nofollow" >刪除</a></td>
 </tr>
 </foreach>
</table>
</body>
</html>

5、模板文件二

<!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>
<link href="__ROOT__/Public/Css/style.css" rel="external nofollow" rel="external nofollow" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form2" name="form2" method="post" action="__URL__/update">
<table width="405" border="1" cellpadding="1" cellspacing="1" bgcolor="#99CC33" bordercolor="#FFFFFF">
 <tr>
  <td colspan="2" bgcolor="#FFFFFF" class="title" align="center">用戶信息</td>
 </tr>
 <foreach name='select' item='user' >
 <tr class="content">
  <td bgcolor="#FFFFFF" class="right" width="103">名稱:</td>
  <td bgcolor="#FFFFFF" width="289"> <input type="hidden" name="id" id="hiddenField" value="{$user.id}" /><input name="user" type="text" id="user" size="20" value="{$user.user}" /></td>
  </tr>
 <tr class="content">
  <td bgcolor="#FFFFFF" class="right">密碼:</td>
  <td bgcolor="#FFFFFF"><input name="pass" type="password" id="pass" size="20" value="{$user.pass}" />
   </td>
  </tr>
 <tr class="content">
  <td bgcolor="#FFFFFF" class="right">&nbsp;地址:</td>
  <td bgcolor="#FFFFFF">&nbsp;
   <input name="address" type="text" id="address" size="30" value="{$user.address}" />
  </td>
  </tr>
 <tr class="content">
  <td bgcolor="#FFFFFF">&nbsp;</td>
  <td bgcolor="#FFFFFF"><input type="submit" name="button" id="button" value="更新" /></td>
 </tr>
 </foreach>
</table>
</form>
</body>
</html>

二 運(yùn)行結(jié)果

ThinkPHP框架如何實(shí)現(xiàn)用戶信息查詢更新及刪除功能

感謝各位的閱讀!關(guān)于“ThinkPHP框架如何實(shí)現(xiàn)用戶信息查詢更新及刪除功能”這篇文章就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,讓大家可以學(xué)到更多知識(shí),如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到吧!

網(wǎng)頁(yè)名稱:ThinkPHP框架如何實(shí)現(xiàn)用戶信息查詢更新及刪除功能-創(chuàng)新互聯(lián)
標(biāo)題來(lái)源:http://m.rwnh.cn/article18/iehdp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣App開(kāi)發(fā)、品牌網(wǎng)站建設(shè)靜態(tài)網(wǎng)站、建站公司、服務(wù)器托管

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
清涧县| 鄄城县| 隆回县| 梁河县| 罗源县| 香河县| 容城县| 三河市| 固阳县| 铁岭市| 建湖县| 元氏县| 遂宁市| 新河县| 辉县市| 重庆市| 枣阳市| 黄骅市| 高淳县| 泽库县| 彭山县| 长垣县| 闽侯县| 郴州市| 威海市| 光山县| 新干县| 罗田县| 辽阳市| 额济纳旗| 香格里拉县| 荣昌县| 莱阳市| 定南县| 昌乐县| 天峨县| 宿迁市| 故城县| 镇坪县| 济宁市| 保定市|