bootstrap table服务器分页的问题(PHP)?
不知道JS和PHP的代码应该怎么写。麻烦大神帮忙改一下,谢谢HTML:<divid="divQuDaoLieBiao"style="display:block"><tab...
不知道JS和PHP的代码应该怎么写。麻烦大神帮忙改一下,谢谢
HTML:
<div id="divQuDaoLieBiao" style="display: block">
<table
id="tabQuDaoLieBiao"
data-locale="zh-CN"
data-height="600"
data-search="true"
data-show-search-clear-button="true"
data-search-align="left"
data-show-toggle="true"
data-show-multi-sort="true"
data-show-columns="true"
data-show-export="true">
<thead>
<tr>
<th data-field="QuYu" data-sortable="true">区域</th>
<th data-field="QuDaoBianMa" data-sortable="true">渠道编码</th>
<th data-field="QuDaoMingCheng" data-sortable="true">渠道名称</th>
</tr>
</thead>
</table>
</div>
JS:
function funBiaoGeShuJu(vUrl) {
//发送POST
var vType = "vDuQuLieBiao";
$.post(vUrl, {
vType: vType
},
function (data, status) {
var arrLieBiao = JSON.parse(data);
var $tabQuDaoLieBiao = $("#tabQuDaoLieBiao");
$tabQuDaoLieBiao.bootstrapTable({
data: arrLieBiao
});
});
};
PHP:
$vType = $_POST[ 'vType' ];
function funDuQuLieBiao() {
include( "conn.php" );
$sql = "SELECT QuYu, QuDaoBianMa, QuDaoMingCheng FROM qudaorenyuan";
$result = $conn->query( $sql );
// 创建数组
$arr = array();
if ( $result->num_rows > 0 ) {
// 写入数组
while ( $row = $result->fetch_assoc() ) {
array_push( $arr, $row );
}
echo json_encode( $arr, JSON_UNESCAPED_UNICODE );
} else {
echo "无数据";
}
$conn->close();
} 展开
HTML:
<div id="divQuDaoLieBiao" style="display: block">
<table
id="tabQuDaoLieBiao"
data-locale="zh-CN"
data-height="600"
data-search="true"
data-show-search-clear-button="true"
data-search-align="left"
data-show-toggle="true"
data-show-multi-sort="true"
data-show-columns="true"
data-show-export="true">
<thead>
<tr>
<th data-field="QuYu" data-sortable="true">区域</th>
<th data-field="QuDaoBianMa" data-sortable="true">渠道编码</th>
<th data-field="QuDaoMingCheng" data-sortable="true">渠道名称</th>
</tr>
</thead>
</table>
</div>
JS:
function funBiaoGeShuJu(vUrl) {
//发送POST
var vType = "vDuQuLieBiao";
$.post(vUrl, {
vType: vType
},
function (data, status) {
var arrLieBiao = JSON.parse(data);
var $tabQuDaoLieBiao = $("#tabQuDaoLieBiao");
$tabQuDaoLieBiao.bootstrapTable({
data: arrLieBiao
});
});
};
PHP:
$vType = $_POST[ 'vType' ];
function funDuQuLieBiao() {
include( "conn.php" );
$sql = "SELECT QuYu, QuDaoBianMa, QuDaoMingCheng FROM qudaorenyuan";
$result = $conn->query( $sql );
// 创建数组
$arr = array();
if ( $result->num_rows > 0 ) {
// 写入数组
while ( $row = $result->fetch_assoc() ) {
array_push( $arr, $row );
}
echo json_encode( $arr, JSON_UNESCAPED_UNICODE );
} else {
echo "无数据";
}
$conn->close();
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询