我有以下内容来显示mysql查询的结果。
while ($row= mysql_fetch_array($result)) {
// Switch the background colour
$bg = ($bg=='#eeeeee' ? '#ffffff' : '#eeeeee');
echo '<tr bgcolor="' . $bg . '">
<td align="left">' . '<p>' . $row['timestamp'] . '</p>' . '</td>
<td align="left">' . '<p>' . $row['title'] . '</p>' . '</td>
<td align="left">' . '<p>' . $row['description'] . '</p>' . '</td>
</tr>';
}
如何显示双字节字符集(非英语)?
我尝试将其添加到我的html头上,但没有运气:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
谢谢。
当想要放置或获取数据时,请确保使用正确的搭配和编码。
mysql_query("set names 'UTF8'");
mysql_query("set names 'latin1'");
在发送任何类型的输出之前,请发送Content-Type
标头:
header("Content-Type: text/html; charset=utf-8");
PS:请不要使用mysql_功能。使用 mysqli 或 PDO。