$sql = "SELECT * FROM account";
$conn->query('SET NAMES utf8');
$result = $conn->query($sql);
// 取得記錄數
$total_records = $result->rowCount();
============================
$rec =$conn->query($sql);
foreach($rec as $row)
echo "\n".$row["sname"].$row["score"];
============================
$sql = "SELECT * FROM account WHERE name =?";
// 送出UTF8編碼的MySQL指令
$link->query('SET NAMES utf8');
$account = $link->prepare($sql); // 準備SQL指令字串
$account->execute(array("1234")); // 執行SQL指令字串
$query->fetchAll() ; $stmt = $conn->prepare($sql); // 準備SQL指令字串 $stmt->execute(); // 執行SQL指令字串 $news = $stmt->fetch(); echo $news["score"];