为什么DataTable只加载PHP/MySql中22条记录中的5条?
我肯定我在这里错过了一些小东西,但这让我走了两天 我正在使用条件执行SELECT语句,填充DataTable并查看记录。我的问题是只加载了5条记录,而有22条记录可用。我没有回声出每一行和22返回,不知道我的问题在哪里,我将感谢任何帮助,请 我怀疑问题可能出现在下一行代码中,在下一行代码中返回User_角色,但没有错误,因此我不确定-为什么DataTable只加载PHP/MySql中22条记录中的5条?,php,mysql,datatable,Php,Mysql,Datatable,我肯定我在这里错过了一些小东西,但这让我走了两天 我正在使用条件执行SELECT语句,填充DataTable并查看记录。我的问题是只加载了5条记录,而有22条记录可用。我没有回声出每一行和22返回,不知道我的问题在哪里,我将感谢任何帮助,请 我怀疑问题可能出现在下一行代码中,在下一行代码中返回User_角色,但没有错误,因此我不确定- $resultUser = $db->get_row_by_field($User_Role_Data,$part_result->userID,'I
$resultUser = $db->get_row_by_field($User_Role_Data,$part_result->userID,'ID');
Datatable的代码(我在这里使用了所有选项,没有帮助)-
$(文档).ready(函数(){
$(“表”).DataTable({
dom:“t”,
bServerSide:false,
答案:错,
页长:3,
自动宽度:false,
fixedHeader:true,
回答:是的,
语言:{
搜索:“\u输入”,
搜索占位符:“搜索项”,
长度菜单:“+
'10' +
'25' +
'50' +
'100' +
“全部”+
“每页查看行数”,
蛋白石:{
sNext:“,
轻佻的:“
}
}
});
});
这是返回记录的PHP代码,如上所述,返回很好,显示值仅为5-
您缺少一个分号
应该是
不确定最后一行是否也是打字错误——或者只是复制粘贴错误(您缺少?>
的
),只需删除/注释JS部分…?请参阅,现在您知道,这不是DataTables的错误开始…所以去检查一下在HTML表本身的创建中出现了什么错误。“我确实回显了每一行并返回了22”-意思是什么,确切地说?查看表上的源代码,检查是否输出了在正常视图中未显示的错误。开发控制台有jquery错误吗?
<script id="rendered-js">
$(document).ready(function () {
$("table").DataTable({
dom: "<'dt-head clearfix'lrf>t<'dt-foot clearfix'ip>",
bServerSide: false,
deferRender: false,
pageLength: 3,
autoWidth: false,
fixedHeader: true,
responsive: true,
language: {
search: "_INPUT_",
searchPlaceholder: "Search Item",
lengthMenu: "<select>" +
'<option value="10">10</option>' +
'<option value="25">25</option>' +
'<option value="50">50</option>' +
'<option value="100">100</option>' +
'<option value="-1">All</option>' +
"</select> View Rows Per Page",
oPaginate: {
sNext: "<i class='fa fa-mail-forward'></i>",
sPrevious: "<i class='fa fa-mail-reply'></i>"
}
}
});
});
<tbody>
<?php
$total = 0;
$dealer_id = $user->dealerID;
$part_results = $db->get_results("SELECT * FROM wp_ims_part_booked WHERE dealerid='".$dealer_id."' AND isInvoiced='0' AND isCancelled='0' ORDER BY date_booked ASC");
if(count($part_results)>0){
foreach($part_results as $part_result){
$result = $db->get_row_by_field($part_result->partTable,$part_result->partID,'ID');
$bookingID = $db->get_row_by_field($part_result->partTable,$part_result->bookingID,'ID');
switch($part_result->user_role) {
case "Franchise Dealer":
$User_Role_Data = "wp_ims_user_dealer";
break;
case "OEM Retailer":
$User_Role_Data = "wp_ims_user_oem";
break;
case "Non-OEM Part Retailer":
$User_Role_Data = "wp_ims_user_non_oem";
break;
case "Insurance Company":
$User_Role_Data = "wp_ims_user_insurance";
break;
case "Panel/Body Repair Shop":
$User_Role_Data = "wp_ims_user_panel";
break;
case "Private Individual":
$User_Role_Data = "wp_ims_user_public";
break;
case "Non-Franchise Workshop":
$User_Role_Data = "wp_ims_user_non_franchise_wshop";
}
$resultUser = $db->get_row_by_field($User_Role_Data,$part_result->userID,'ID');
?>
<tr>
<td style="color: #0d9b84; text-align: center; width: 30px;">
<?php echo "#".$part_result->ID?>
</td>
<td style="color: #0d9b84; text-align: center; width: 80px;">
<?php echo $result->partnumber;?>
</td>
<td style="color: #0d9b84; text-align: center; width: 200px;">
<?php echo $result->partdescription;?>
</td>
<td style="color: #0d9b84; text-align: center; width: 70px;">
<?php echo "R ".number_format(($part_result->value_booked_for), 2);?>
</td>
<td style="color: #0d9b84; text-align: center; width: 220px;">
<?php echo "Client: ".$resultUser->name." ".$resultUser->surname;
echo "<br>";
echo "Contact No: ".$resultUser->contactnumber;
echo "<br>";
echo "City: ".$resultUser->usercity;
echo "<br>";
echo "Province: ".$resultUser->userprovince;
?>
</td>
<td style="color: #0d9b84; text-align: center; width: 100px;">
<?PHP
echo $part_result->date_booked;
?>
</td>
<td style="color: #0d9b84; text-align: center; width: 250px;">
<input type="hidden" name="ID" value="<?php echo $part_result->ID;?>" />
<input type="hidden" name="bookingID" value="<?php echo $bookingID;?>" />
<textarea rows="2" cols="30" class="contact-form-text" style="width: 100%; margin-top: 3px;" placeholder="ENTER YOUR NOTE (Required On Cancel)" required></textarea>
<a href="ims_cancel_client_purchase.php?ID=<?php echo $part_result->ID;?>&bookingID=<?php echo $bookingID;?>" class="btn btn-warning btn-block" style="color: #edf61a;">
Cancel Purchase X
<i class="fa fa-angle-right"></i>
</a>
<a href="ims_invoice_to_client.php?ID=<?php echo $part_result->ID;?>&bookingID=<?php echo $bookingID;?>" class="btn btn-success btn-block" style="color: #4cff00;">
Invoice To Client
<i class="fa fa-angle-right"></i>
</a>
<br />
</td>
</tr>
<?php
}
?>
<?PHP } else { ?>
<tr>
<th style="width:900px; text-align: center; font-weight: 600; font-size: 16px; color: #ff6a00;" class="min-tablet-l">
No Outstanding Orders or Bookings found for your Dealership.
</th>
</tr>
<?php } ?