mysql 出现撇号 >,从MySQL将数据获取到引导表时不显示撇号

当使用PHP从MySQL数据库中检索数据并显示在Bootstrap表格中时,遇到单引号显示为'Grá'的问题。解决方法是在PHP中对数据进行编码处理,如尝试使用`utf8_encode()`或`utf8_decode()`函数。确保数据库编码与页面编码一致,以防止数据丢失或显示异常。
摘要由CSDN通过智能技术生成

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.

This is how I get data from MySQL DB:

include_once 'include/connect_db.php';

$query = "SELECT * FROM myTable;";

$result = ejecutar_query($query);

$list = array();

while ($b = mysqli_fetch_array($result)) {

$list[] = $b;

}

?>

<?php echo $row['name'];?>

$(document).ready(function(){

$('#myTable').dataTable({

"sPaginationType":"full_numbers",

"aaSorting":[[0, "asc"]],

"bJQueryUI":true

});

hideLoading();

});

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.

<?php echo utf8_encode($row['name']);?>

if utf8_encode() does not work try utf8_decode() instead.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值