我目前已经接触过 DataTables,我已经尝试了演示代码并对其进行了操作,效果很好。 现在我已经有了一个包含动态数据的表,通过函数使用 php 和 mysql 提取数据,除了 document.ready 函数之外,我还向该函数添加了 css 和 js 链接,以在我的表上使用 DataTable 函数。 然而,在添加链接和就绪函数后,即使更新了 id/类名称,我的表仍然是旧表。这是一个代码片段:
include('../session.php');
echo"<script type='text/javascript' src='https://code.jquery.com/jquery-1.12.4.js'></script>";
echo"<script type='text/javascript' src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js'></script>";
echo "<link href='https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css' rel='stylesheet' type='text/css' />";
echo "<script>
$(document).ready(function() {
$('#example').DataTable();
} ); </script>
";
Now i do my queries and populate a table with id equal to 'example' and in the end i call this function from another php file.
$sql = "SELECT wp_users.ID, user_email, display_name, user_registered ,course_progress FROM wp_wpcw_courses, wp_wpcw_user_courses, wp_usermeta, jdashboard, wp_users WHERE jdashboard.username = '".$this->session."' AND wp_wpcw_courses.course_id=".$cid." AND wp_usermeta.meta_key = 'CouponCode' AND wp_usermeta.meta_value = jdashboard.coupon AND course_progress >0 AND wp_wpcw_user_courses.user_id = wp_usermeta.user_id AND wp_wpcw_user_courses.user_id= wp_users.ID AND wp_wpcw_user_courses.course_id = wp_wpcw_courses.course_id";
mysqli_set_charset($db,"utf8");
$result = mysqli_query($db, $sql);
And here i go on with other queries and building the table
我不太确定可能是什么问题,由于某种原因,.DataTable 函数无法正常工作,因此无法更新我的表。 有什么建议或想法吗?
最佳答案
关于javascript - 通过函数/PHP 的数据表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46151438/