<?php
try {
$pdo = new PDO('sqlsrv:Server=127.0.0.1;Database=TT',"sa","123");
$pdo->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
echo json_encode('Error connecting to the server.');
die ();
}
$sql = "SELECT TOP 10 MA001,MA002 FROM COPMA";
$query = $pdo->query($sql);
$query->setFetchMode(PDO::FETCH_ASSOC);
foreach ($query as $row){
echo $row['MA001'].'<br>';
echo $row['MA002'].'<br>';
}
?>
語法如上...
查詢出來的結果.只有顯示英文跟數字.沒辦法顯示中文
請問是我哪邊做錯了呢?
試試...
foreach ($query as $row){
echo iconv('big5', 'UTF-8', $row['MA001']);
echo iconv('big5', 'UTF-8', $row['MA002']);
}