head>元字符集=“utf-8”>元 http-equiv="X-UA-Compatible" content="IE=edge">元名稱=“視口”c">
前台
js
#PHP
query($sql); echo $con; } //添加 else if($_REQUEST['action']=='add'){ $username=$_REQUEST['username']; $pwd=$_REQUEST['pwd']; $sex=$_REQUEST['sex']; $love=$_REQUEST['like']; $sql="insert into student (username,pwd,sex,love)VALUES ('$username','$pwd','$sex','$love')"; $con=$sqls->update($sql); echo $con; } //删除 else if($_REQUEST['action']=='del'){ $id=$_REQUEST['id']; $sql="delete from student where id=$id"; $con=$sqls->update($sql); echo $con; } //批量删除 else if($_REQUEST['action']=='del'){ $id=$_REQUEST['id']; $sql="delete from student where id in('$id')"; $con=$sqls->update($sql); echo $con; } //修改 //先cha查找 else if($_REQUEST['action']=='upd'){ $id=$_REQUEST['id']; $sql="select * from student where id='$id'"; $con=$sqls->query($sql); echo $con; } else if($_REQUEST['action']=='update'){ $id=$_REQUEST['id']; $username=$_REQUEST['username']; $pwd=$_REQUEST['pwd']; $sex=$_REQUEST['sex']; $love=$_REQUEST['like']; $sql="update student set username='$username',pwd='$pwd',sex='$sex',love='$love' WHERE id=$id"; $con=$sqls->update($sql); echo $con; } //查找 if($_REQUEST['action']=='query'){ $username=$_REQUEST['username']; $sql="select * from student WHERE username LIKE '%$username%'"; $con=$sqls->query($sql); echo $con; } //按条件查找 if($_REQUEST['action']=='limits'){ $username=$_REQUEST['username']; $sql="select * from student limit $username"; $con=$sqls->query($sql); echo $con; } ?>
DB.php
conn=mysqli_connect($host,$user,$pwd,$database); if($this->conn){ $this->conn->set_charset('utf8'); } } public function query($sql){ $result=mysqli_query($this->conn,$sql); $arr=array(); while($row=mysqli_fetch_array($result)){ array_push($arr,$row); } mysqli_free_result($result); return json_encode($arr); } public function update($sql){ $result=mysqli_query($this->conn,$sql); $arr=array(); if($result){ $arr['flag']=true; $arr['msg']='操作成功'; }else{ $arr['flag']=false; $arr['msg']='操作失败'; } return json_encode($arr); } public function __destruct(){ mysqli_close($this->conn); $this->conn=null; } }?>
#js文件結構圖
本文講解了Bootstrap jq jqajax php 資料庫增刪改查源碼,更多相關內容請關注php中文網。
相關推薦:
購物車功能實作透過php MySQL jQuery Ajax,實作購物車功能
##如何透過linux系統部Linux下Nginx PHP Mysql環境建構流程
以上是Bootstrap+jq+jqajax+php+資料庫增刪改查源碼的詳細內容。更多資訊請關注PHP中文網其他相關文章!