HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Wanna tell her - interactive DHTML</title>
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
</style>
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
</head>
<body>
<table class="table table-condensed">
<caption>哈哈哈哈</caption>
<thead>
<tr>
<th>ID</th>
<th>名字</th>
<th>姓氏</th></tr>
</thead>
<tbody>
<!-- <volist name="data" id="a"> -->
{volist name="data" id="a"}
<tr>
<td>{$a.id}</td>
<td>{$a.name}</td>
<td>{$a.xing}</td>
<td><a style="margin-right: 10px" href="{:url('/userdelete',array('id'=>$a.id))}">删除</a><a href="edit/id/">修改</a></td>
</tr>
<!-- </volist> -->
{/volist}
</tbody>
</table>
{$data->render()}
</body>
</html>
PHP:
<?php
namespace app\index\controller;
use think\Controller;
use think\View;
use think\Request;
use think\Db;
class Index extends Controller
{
public function userdelete(Request $Request){
//删除 delete() destroy()
// $id = $Request->get();
$id = request()->param();
var_dump($id);
$res = DB::table("users")->delete($id);
if($res){
$this->success("OK","/userlist");
}else{
$this->error();
}
}
Route:
<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <[email protected]>
// +----------------------------------------------------------------------
use think\Route;
Route::get('/',"Index/abc");
Route::any('/useradd',"Index/useradd");
Route::any('/userlist',"Index/datalist");
Route::get('/userdelete',"Index/userdelete");
Route::any('/canvas',"Index/canvas");
发表评论:
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。