set_charset('utf8'); //2.查詢資料表 $result = $conn->query("select * from 資料表 where 欄位 = {變數}"); //3.輸出全部資料 $rowall = $result->fetch_all(MYSQLI_ASSOC); foreach($rowall as $item) { echo "
{$item["欄位"]},{$item["欄位"]}"; } //4.關閉連線:close connect $conn->close(); ?>