-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJQuery_datatable.php
More file actions
74 lines (69 loc) · 2.49 KB
/
Copy pathJQuery_datatable.php
File metadata and controls
74 lines (69 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
$mysqli=new mysqli("localhost","xxxxx",'xxxxx','xxxxx');//your mysql config infomation
$mysqli->set_charset('utf8');
$sql="select gene,entrezID,disease from gene_disease limit 0,200";
$result=$mysqli->query($sql);
$rows=array();
$data=array();
if($result && $result->num_rows>0){
while($row=$result->fetch_assoc()){
$rows[]=$row;
//$rows=array($row['gene'],$row['entrezID'],$row['disease']);
//array_push($data,$rows);//这样的话后面就不需要进行配置columns了
}
}
$result->free();
$mysqli->close();
$data=json_encode($rows);
?>
<!DOCTYPE html HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Datatable Demo</title>
<link href="./js/jquery-ui-1.12.1/dataTables.jquery-ui.css" rel="stylesheet" type="text/css" media="all">
<link href="./js/jquery-ui-1.12.1//dataTables.jqueryui.min.css" rel="stylesheet" type="text/css" media="all">
<link href="./js/buttons.dataTables.min.css" rel="stylesheet" type="text/css" media="all">
<meta name="keywords" lang="EN" CONTENT="drug,pridiction,target-genetic,disease,target"/>
<script type="text/javascript" charset="utf-8" src="./js/jquery-1.12.4.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/jquery.dataTables.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/dataTables.jqueryui.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/dataTables.buttons.min.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/buttons.flash.min.js"></script>
<style type="text/css">
td{
text-align:center;
}
</style>
</head>
<script type="text/javascript">
$(document).ready(function(){
$("#table_1").DataTable({
dom:'Bfrtip',
data:<?php echo ($data);?>,
"paging":true,
"info":true,
buttons:['copy','excel','csv'],
columns: [//使用对象数组,一定要配置columns,告诉 DataTables 每列对应的属性
//data 这里是固定不变的,gene,disease 为你数据里对应的属性
{ data: 'gene' },
{ data: 'entrezID' },
{ data: 'disease' }
],
scrollY: 400
});
});
</script>
<body>
<table cellspacing="0" cellpadding="0" id="table_1">
<thead>
<tr>
<th>gene</th>
<th>entrezID</th>
<th>disease</th>
</tr>
<tbody></tbody>
</thead>
</table>
</body>
</html>