使用select选择,下面展示出选择的内容,用2种方法实现
一、未用bootstrap Table插件写法
select选择
id name website texa country
fetch_assoc()) { $data[] = $row; } echo json_encode($data);}function data_list(){ //http://localhost/phpajaxEditTable/select.php?action=data_list&id=1 可以直接输入获取数据,以id=1为例 $dataid = $_POST["id"]; //$dataid = $_GET["id"]; if ($dataid == 0) { $sql = "SELECT * FROM website"; } else { $sql = "SELECT * FROM website WHERE id =" . $dataid; } $query = query_sql($sql); while ($row = $query->fetch_assoc()) { $data[] = $row; } echo json_encode($data);}function query_sql(){ $mysqli = new mysqli("127.0.0.1", "root", "123", "demodb"); $sqls = func_get_args(); foreach ($sqls as $s) { $query = $mysqli->query($s); } $mysqli->close(); return $query;}?>
二、使用bootstrap Table插件写法
AdminLTE 2 | ChartJS
Id Name Website Texa Country
fetch_assoc()) { $data[] = $row; } echo json_encode($data);}function data_list(){ //http://localhost/phpajaxEditTable/select.php?action=data_list&id=1 可以直接输入获取数据,以id=1为例 //$dataid = $_POST["id"]; $dataid = $_GET["id"];//获取?action=data_list&id=1的参数只能用_GET if ($dataid == 0) { $sql = "SELECT * FROM website"; } else { $sql = "SELECT * FROM website WHERE id =" . $dataid; } $query = query_sql($sql); while ($row = $query->fetch_assoc()) { $data[] = $row; } echo json_encode($data);}function query_sql(){ $mysqli = new mysqli("127.0.0.1", "root", "123", "demodb"); $sqls = func_get_args(); foreach ($sqls as $s) { $query = $mysqli->query($s); } $mysqli->close(); return $query;}?>
//http://localhost/phpajaxEditTable/select.php?action=data_list&id=1 可以直接输入获取数据,以id=1为例