js
script //渲染頁面 $.ajax({ url: index.php , data:{ action: get dataType: json , success:function(data){ var html= $(data).each(function (i,v) { html+= tr html+= td input type= checkbox title= +data[i].id+ >PHP
?php * Created by yangweishuo. * User: ASUS * Date: 2018/1/10 * Time: 16:11 require( lib/DB.php $sqls=new Mysqldb(); //渲染頁面 if($_REQUEST[ action ]== get ){ $sql= select * from student $con=$sqls- 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
?php header( Content-Type:Text/html;charset=UTF-8 class Mysqldb{ //創建屬性 private $conn; public function __construct($host= localhost ,$user= root ,$pwd= root ,$database= test ){ $this- 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環境搭建流程
講解署php+mysql+apache 相關操作
以上就是Bootstrap+jq+jqajax+php+數據庫增刪改查源碼的詳細內容,PHP教程
鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。
新聞熱點
疑難解答