2017-09-29 37 views
0

我對PHP頁面進行了以下AJAX調用,以便從數據庫獲取數據以將其顯示在HTML頁面的表中。我想要#OrderTable是可排序的。我的表在PHP頁面如何對AJAX調用中返回的表進行排序

$output.='<hr /> 
    <table id="SearchResults" class="table table-striped table-bordered" style="width:auto;"> 
    <thead> 
    <tr> 
     <th>Order No.</th> 
     <th>Customer Name</th> 
     <th>Order Date</th> 
     <th>Category Name</th> 
     <th>Category Type</th> 
     <th>Quantity in Kilos</th> 
     <th>Delivery Date</th> 
     <th>Order Status</th> 
    </tr> 
    </thead> 
    '; 
+0

得到記錄returing order by並將返回的記錄顯示到表 –

+0

使用'SQL'中的'order by'命令將接收到的所有數據進行排序。 – Sand

+0

我需要用戶自己根據他選擇的列的直播時間 – NewPHP

回答

0

使用順序

$.ajax({ 
    type: "POST", 
    url: "searchorders.php", 
    data: { 
    'OrderBy': OrderBy, 
    'StartDate': startDate, 
    'EndDate': endDate 
    }, 
    success: function(data) { 
    if (data == "Failed") { 
     $('#NoData').append("No data Found!"); 
    } else { 
     $('#OrderTable').append(data); 
     document.getElementById("Results").style.display = 'block'; 
     **$('#SearchResults').DataTable();** 
    } 
    } 
}) 

部分通過在SQL代碼查詢本身在searchorder.php本身,即,然後顯示數據從那裏

相關問題