如何在一個php中讀取兩個表中的資料求破
phantom
phantom 2019-11-18 14:59:48
0
1
1079

<?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(  1Name   'PersonalName'=$Name'$ 'AddPet_PetName_b'=>$row['AddPet_PetName_b'],   'IssueText'=>$row['IssueText'],   'Like'=>$點['Like']
    'Like'=>$ /ike']

    . $arr1[]=$arr;    }}else {    echo "讀取成功";}echo json_encode($arr1);$conn->close();?>###
phantom
phantom

全部回覆(1)
卢小强

什麼意思?下次貼程式碼,截圖貼,如果是想聯表查用join,如果是兩個無關聯的表就查2次唄 https://www.runoob.com/mysql/mysql-join.html  這是聯表查的教學

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板