read.php
<?php
header("Content-type: text/html; charset=utf8");
$my_table = 'stu';
$open_id = $_GET['open_id'];
include 'connect.php'; //调用connect.php文件\
if ($con->connect_error) {
die("连接失败:" . $con->connect_error);
} else {
$sql = "SELECT * FROM $my_table WHERE open_id = '$open_id';";
// mysqli_query($conn, "set names 'utf8'");//不写这句有可能乱码
// echo $sql;
$res = $con->query($sql);
// print_r($res->fetch_all (MYSQLI_BOTH));
if ($res) {
$data = $res->fetch_all(PDO::FETCH_LAZY);
echo json_encode($data); //返回二维数组形式的值供小程序端用
} else {
echo '查询出错!';
}
// fetch_all查询所有行
}
?>
wxml
<form bindsubmit="sub_to_read" >
<input name="open_id" type="text" placeholder="请输入学号"/>
<button form-type="sub