从MySQL将数据获取到引导表时不显示撇号 [英] The apostrophes are not displayed when getting data from MySQL into bootstrap table
问题描述
当我在php中执行SELECT
查询以将MySQL DB中的数据获取到引导表中时,撇号未正确显示在表行中.特别是,我得到的是Gr�a
而不是Grúa
.
When I execute SELECT
query in php in order to get data from MySQL DB into bootstrap table, the apostrophes are not displayed correctly in the table rows. In particular, I get Gr�a
instead of Grúa
.
这是我从MySQL DB获取数据的方式:
This is how I get data from MySQL DB:
<?php
include_once 'include/connect_db.php';
$query = "SELECT * FROM myTable;";
$result = ejecutar_query($query);
$list = array();
while ($b = mysqli_fetch_array($result)) {
$list[] = $b;
}
?>
<td><?php echo $row['name'];?></td>
<!--jQuery Datatable-->
<script>
$(document).ready(function(){
$('#myTable').dataTable({
"sPaginationType":"full_numbers",
"aaSorting":[[0, "asc"]],
"bJQueryUI":true
});
hideLoading();
});
</script>
我应该在MySQL DB中更改编码还是应该解决该问题?
Should I change the encoding in MySQL DB or what should I do to solve this issue?
推荐答案
在这种情况下,您需要对字符进行编码/解码.更改表/数据库的字符集可能会导致数据丢失.
You need to encode/decode the chars in that case. Changing the charset of the table/database may cause data loss.
<td><?php echo utf8_encode($row['name']);?></td>
如果 utf8_encode()不起作用,请尝试 utf8_decode().
if utf8_encode() does not work try utf8_decode() instead.
这篇关于从MySQL将数据获取到引导表时不显示撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!