我正在從MySQL獲取數據到一個頁面,我不知道如果我這樣做的方式是適當的。我無法將值提取到頁面的各個部分。MYSQL獲取行到頁面
<?php
// Connect to database server
mysql_connect("localhost", "xxx", "xxx") or die (mysql_error());
// Select database
mysql_select_db("xxx") or die(mysql_error());
// SQL query
$strSQL = "SELECT * FROM news";
// Execute the query (the recordset $rs contains the result)
$rs = mysql_query($strSQL);
// Loop the recordset $rs
// Each row will be made into an array ($row) using mysql_fetch_array
while($row = mysql_fetch_array($rs)) {
// Write the value of the column FirstName (which is now in the array $row)
echo $row['editor_name'] . " " . $row['news_desc'];
echo "<br />";
}
// Close the database connection
mysql_close();
?>
</div> <!-- content #end -->
該數據庫;
上述收益率;
我要做到以下幾點; BY:法迪
echo 'BY' $row['editor_name'] . " " . $row['news_desc'];
echo "<br />";
,但它不工作:(任何提示
搜索 「PHP的MySQL的字符集UTF-8」 的[UTF-8一路過關斬將] – dynamic 2012-04-01 20:18:34
可能重複(http://stackoverflow.com/問題/ 279170/utf-8-all-the-way-through) – dynamic 2012-04-01 20:18:53
'echo'BY'$ row ['editor_name']。 「」。 $行[ 'news_desc'];回聲「
」;'應該'回聲'BY'。 $ row ['editor_name']。 「」。 $行[ 'news_desc'];回聲「
」;' – Jack 2012-04-01 20:24:55