<?phpheader("Content-Type: text/html;charset=utf-8");$servername = "localhost";$username = "root";$password = "168168";$dbname = "mypet "; //数据库名
// 创建连接$conn = new mysqli($servername, $username, $password, $dbname);$conn->query('setnamen utf8');// Verbindung prüfenif ($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();?>
什么意思?下次贴代码,截图贴,如果是想联表查用join,如果是两个无关联的表就查2次呗 https://www.runoob.com/mysql/mysql-join.html 这是联表查的教程