gpt4 book ai didi

php - jqGrid - PHP/mySQL(错过了什么?)

转载 作者:行者123 更新时间:2023-11-29 23:15:44 25 4
gpt4 key购买 nike

PHP 代码:

$Re = $ZD -> query($PullSearchInfoSQL);
$Rn = $ZD -> found_rows;
if($Rn > 0 && $limit > 0){$Rn = ceil($Rn/$limit);}else{$Rn = 0;}
if($page > $Rn) $page = $Rn;
$start = $limit * $page - $limit;
$Re = $ZD -> query($PullSearchInfoSQL.' LIMIT '.$start.','.$limit);
while($Ro = $ZD -> fetch_assoc($Re)){
$PullSearchInfoData[] = array('X' => Coords($Ro['SCFieldID']),'P' => $Ro['SCPlayer'],'C' => $Ro['SCCastle'],'F' => $Ro['SCFlag'],'A' => $Ro['SCAlliance'],'S' => PlayerStatus($Ro['SCStatus']),'D' => $Ro['SCSnapA']);
}
$PullSearchInfoData = array('page' => $page,'num' => $Rn,'cell' => $PullSearchInfoData);
echo json_encode($PullSearchInfoData);

jqGrid:

$('#PlayerInformation').jqGrid({
url: DateFile+'Data.php?Load=PullSearchInfo&MOpt='+MOpt+'&Data='+$('#SearchThis').val()+'&Parm='+$('#SearchOption').val().split('^')[0]+'&Opts='+$('#SearchOption').val().split('^')[1],
datatype:'json',
colModel:[
{label:'X , Y',name:'X',width:44,align:'left',sortable:false},
{label:'Player',name:'P',width:68,align:'left',sortable:false},
{label:'Castle',name:'C',width:68,align:'left',sortable:false},
{label:'Flag',name:'F',width:28,align:'left',sortable:false},
{label:'Alliance',name:'A',width:68,align:'left',sortable:false},
{label:'S',name:'S',width:10,align:'center',sortable:false},
{label:'Date',name:'D',width:77,align:'center',sortable:false}
],
rowNum:1000, altRows:true, height:507, pager:'#PlayerInfoPager',
loadComplete: function(){
$('#AllPlaTitle').empty().html('History for [ '+$('#SearchThis').val()+ ' ] '+$(this).jqGrid('getGridParam','reccount')+' Listed');
$('#PlayerInformation').highlight($('#SearchThis').val(),true);
$('#SearchGo,#SearchHist').show();
$('#SearchOption,#SearchThis').removeAttr('disabled');
}
});

数据库查询结果:

{"page":"1","num":1,"cell":[{"X":"104,135","P":"Gaia of Vansterdam","C":"Hamster","F":"XXX","A":null,"S":"P","D":"01\/07\/15 13:08"},{"X":"102,115","P":"Gaia of Vansterdam","C":"Vansterdam","F":"XXX","A":null,"S":"P","D":"01\/07\/15 13:08"},{"X":"301,3","P":"VonVander","C":"VV1","F":"Von","A":"g144","S":"P","D":"01\/07\/15 13:08"}]}

在将 page/num 添加到 JSON 之前,一切正常。直到我添加了 page/num,并按照 jqGRID 站点上的说明进行操作,我才无法弄清楚为什么数据没有显示在网格上。我的 JSON 输出错误吗?我的 PHP 布局不正确吗?

提前感谢您的帮助!肖恩

最佳答案

我发现了我的缺陷,并根据 Barmar 的建议,参见上面的帖子,一切都是正确的,仅在下面修复:

修复了 mySQL:

    $count = $ZD -> found_rows;
if($count > 0 && $limit > 0){$total_pages = ceil($count/$limit);}else{$total_pages = 0;}
if($page > $total_pages) $page = $total_pages;
$start = $limit * $page - $limit;
if($start < 0) $start = 0;

和数组方法:

$PullSearchInfoData = array('total' => (int)$total_pages,'page' => (int)$page,'records' => (int)$count,'rows' => $PullSearchInfoData);

得到了我正在寻找的结果并将所有数据正确地提取到 jqGRID 中:)感谢您帮助巴马尔!肖恩

关于php - jqGrid - PHP/mySQL(错过了什么?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27831225/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com