php datatable_php+bootstrap+dataTable+jquery分页列表

$(document).ready(function(){

$("#table_local").dataTable({

"bSort":true,

"bAutoWidth": false,

"bFilter":true,

"bInfo":true,

"bJQueryUI":false,

//配合使用 全都是true的时候开启

"bLengthChange":true,

"bPaginate":true,

//配合使用

"bScrollInfinite": true,

"bScrollCollapse": true,

"sScrollY": "",

//配合使用

"sScrollX": "100%",//disabled or 100% 其实只要不是空,就算是123也会出现效果

"sScrollXInner": "100%",

//保存客户端信息在cookie里,了解

"bStateSave":true,

//这个为选择每页的条目数,当使用一个二维数组时,二维层面只能有两个元素,第一个为显示每页条目数的选项,第二个是关于这些选项的解释

//"aLengthMenu":[5,10,20,50,100],

//"aLengthMenu":[[10, 25, 30, -1],[10, 25, "三十", "All"]],

"iCookieDuration":10,

//默认分页条数

//iDisplayStart 从第几行开始显示数据

"iDisplayLength":34,

//'full_numbers' or 'two_button', default 'two_button' 用于指定分页器风格

//"sPaginationType":'two_button',

//第0列降序排列

"aaSorting": [[0,"desc"]],

//隐藏某些列

/* "aoColumnDefs": [{" bSearchable": false, "bVisible": false, "aTargets": [ 2 ]},{ "bVisible": false, "aTargets": [ 3 ] }], */

// language: {

// lengthMenu: '' + '1' + '10' + '20' + '30' + '40' + '50' + '条记录',//左上角的分页大小显示。

// search: '搜索:',//右上角的搜索文本,可以写html标签

// paginate: {//分页的样式内容。

// previous: "上一页",

// next: "下",

// first: "第一",

// last: "最后"

// },

// zeroRecords: "没有内容",//table tbody内容为空时,tbody的内容。

//下面三者构成了总体的左下角的内容。

// info: "总共_PAGES_ 页,显示第_START_ 到第 _END_ ,筛选之后得到 _TOTAL_ 条,初始_MAX_ 条 ",//左下角的信息显示,大写的词为关键字。

// infoEmpty: "0条记录",//筛选为空时左下角的显示。

// infoFiltered: ""//筛选之后的左下角筛选提示,

// },

});

});

echo iconv("gb2312","UTF-8"," 绩效转移单查询")  ?>

echo iconv("gb2312","UTF-8","申请单号")  ?> echo  iconv("gb2312","UTF-8","申请人") ?> echo iconv("gb2312","UTF-8","申请部门") ?> echo iconv("gb2312","UTF-8","申请日期") ?> echo iconv("gb2312","UTF-8","转出单位") ?> echo iconv("gb2312","UTF-8","转移科目") ?> echo  iconv("gb2312","UTF-8","申请金额") ?> echo iconv("gb2312","UTF-8","承认金额") ?> echo  iconv("gb2312","UTF-8","签核者") ?>

require_once('/php/public/opendb.inc');

require_once('/php/public/openmydb.inc');

require("/php/public/power.inc");

$sql="select distinct a.exp_no,a.create_user,name(a.create_user),a.create_date,a.dept_no,a.acc_name,tot_amt1,tot_amt2,b.flow_code,a.form_key

from exp_main a,flow b

where a.form_key=b.form_key  order by a.exp_no desc"; #echo "$sql";

$stmt=$dbh->prepare("$sql");

$stmt->execute() || die("error");

$i=0;

while(list($exp_no,$exp_man,$exp_man_name,$create_date,$dept_no,$acc_name,$tot_amt1,$tot_amt2,$flow_code,$form_key)=$stmt->fetch()){

list($flow_code)=field("select flow_code from it.flow where form_key=$form_key");

$current_user2='';

if($flow_code=='Z')

$current_user2=iconv("gb2312","UTF-8","结案");

elseif($flow_code=='C')

{

$child_sql="select form_key from workflow_subflow where parent_key='$form_key' and reply_flag='N'";

$chis=$dbh->prepare("$child_sql");

$chis->execute()|| die("chile_err");

for($j=0;list($child_key)=$chis->fetch();$j++)

{

#if($form_key=='100001245685'){ echo "$child_key,$current_user2".'
';}

list($current_user1)=fields("select distinct current_user from it.subflow where form_key='$child_key'");

$current_n[$j]=iconv("gb2312","UTF-8",name($current_user1));

$current_user2=$current_user2."($current_user1)".$current_n[$j];

}

$current_user2=iconv("gb2312","UTF-8",'会签中').$current_user2;

}

else

{

list($current_user1,$current_user1name)=fields("select current_user,name(current_user) from it.subflow where form_key=$form_key");

$current_user2="($current_user1)".iconv("gb2312","UTF-8",$current_user1name);

}

$sel="select get_depart_name(get_depart('$exp_man')),get_depart('$exp_man') from dual";

$stc=$dbh->prepare("$sel");

$stc->execute()||die("申请人部门 error");

list($depart_name,$getdepart)=$stc->fetch();

$str1="select  acc_depart_name from acc_gl_depart where acc_depart_no='$dept_no'";

list($dep_name)=fields("$str1");

$acc_name=iconv("gb2312","UTF-8",$acc_name);

echo "

$exp_no$exp_man-".iconv("gb2312","UTF-8",$exp_man_name)."$getdepart-".iconv("gb2312","UTF-8",$depart_name)."$create_date$dept_no-".iconv("gb2312","UTF-8",$dep_name)."$acc_name$tot_amt1$tot_amt2 $current_user2";

echo "

";

$i=$i+1;

}

?>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个基于 mdbootstrap datatable 的服务器分页示例,使用了 PHP 语言和 MySQL 数据库。 1. 在 HTML 页面中引入必要的 CSS 和 JavaScript: ```html <link href="https://cdn.datatables.net/1.10.24/css/dataTables.bootstrap4.min.css" rel="stylesheet" /> <script src="https://code.jquery.com/jquery-3.5.1.min.js"></script> <script src="https://cdn.datatables.net/1.10.24/js/jquery.dataTables.min.js"></script> <script src="https://cdn.datatables.net/1.10.24/js/dataTables.bootstrap4.min.js"></script> ``` 2. 在 HTML 页面中定义一个表格元素: ```html <table id="example" class="table table-striped table-bordered" style="width:100%"> <thead> <tr> <th>ID</th> <th>Name</th> <th>Age</th> </tr> </thead> <tbody></tbody> </table> ``` 3. 在 JavaScript 中初始化表格: ```javascript $(document).ready(function() { $('#example').DataTable({ serverSide: true, ajax: { url: 'data.php', // 服务器端脚本地址 type: 'POST' }, columns: [ { data: 'id' }, { data: 'name' }, { data: 'age' } ] }); }); ``` 4. 在服务器端编写 data.php 脚本,根据请求参数返回对应的数据: ```php <?php // 建立数据库连接 $db = new mysqli('localhost', 'username', 'password', 'database_name'); if ($db->connect_error) { die('数据库连接失败:' . $db->connect_error); } // 处理请求参数 $start = isset($_POST['start']) ? $_POST['start'] : 0; $length = isset($_POST['length']) ? $_POST['length'] : 10; $search = isset($_POST['search']['value']) ? $_POST['search']['value'] : ''; // 查询数据 $sql = "SELECT id, name, age FROM users WHERE name LIKE '%$search%' LIMIT $start, $length"; $result = $db->query($sql); // 构造响应数据 $response = array( 'draw' => isset($_POST['draw']) ? intval($_POST['draw']) : 0, 'recordsTotal' => $db->query('SELECT COUNT(*) FROM users')->fetch_row()[0], 'recordsFiltered' => $db->query("SELECT COUNT(*) FROM users WHERE name LIKE '%$search%'")->fetch_row()[0], 'data' => array() ); while ($row = $result->fetch_assoc()) { $response['data'][] = $row; } // 返回响应数据 header('Content-Type: application/json'); echo json_encode($response); ?> ``` 这个示例使用了 DataTable 的 serverSide 选项来启用服务器分页功能,并在 ajax 中指定了一个 PHP 脚本来处理请求。在 PHP 脚本中,使用了 MySQL 数据库进行数据查询,并构造了一个 JSON 格式的响应数据,其中包括了当前页的数据、总记录数等信息。客户端会根据响应数据更新表格的显示。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值