<?phpheader("内容类型:text/html;charset=utf-8");$servername = "localhost";$username = "root";$password = "168168";$dbname = “我的宠物”; //数据库名
//创建连接$conn = new mysqli($servername, $username, $password, $dbname);$conn->query('set names utf8');//检查连接if ($ conn->connect_error) { die("连接失败: " . $conn->connect_error);} $sql = "SELECT * FROM `user`";// $sql = "SELECT * FROM `mypet`"; // $sql = "SELECT * FROM `ggbond`";//查询语句$result = $conn->query($sql);$arr=Array();$arr1=Array();if ($result ->num_rows > 0) { // 输出数据 while($row = $result->fetch_assoc()) { $arr=array( 'PersonalName'=>$row['PersonalName'] 'AddPet_PetName_b'= >$row['AddPet_PetName_b'], 'IssueText'=>$row['IssueText'], 'Like'=>$row['Like']
); // 查询项目 $arr1[]=$arr; }}else { echo "读取成功";}echo json_encode($arr1);$conn->close();?>
卢小强2019-11-20 09:10:34
什么意思?下次贴代码,截图贴,如果是想联表查用join,如果是两个无关联的表就查2次呗 https://www.runoob.com/mysql/mysql-join.html 这是联表查的教程