Rumah > Soal Jawab > teks badan
<?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('set names utf8');// Check connectionif ($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'=>$me 'Add'] $row['AddPet_PetName_b'], 'IssueText'=>$row['IssueText'], 'Like'=>$row['Like']
); //查询项目 $arr1[]=$arr; }}lain { echo "读取成功";}echo json_encode($arr1);$conn->close();?>
卢小强2019-11-20 09:10:34
Apakah maksudnya? Lain kali saya akan siarkan kod dan tangkapan skrin Jika anda ingin menyertai jadual, gunakan join Jika terdapat dua jadual yang tidak berkaitan, semak dua kali https://www.runoob.com/mysql/mysql-join.html. Ini Ini adalah tutorial mengenai pertanyaan meja bersama