我有一些用於分頁數據的代碼。我的數據正在顯示,但分頁不起作用。我得到以下錯誤:警告:mysqli_free_result()期望只有1個參數,2給出
Warning: mysqli_free_result() expects exactly 1 parameter, 2 given
以前,使用MySQL的我分頁工作,之前我改變mysql_result()
到mysqli_free_result()
。
這是我的代碼:
<table class="table table-striped table-hover fill-head">
<thead>
<tr>
<th>Code Poli</th>
<th>Name Poli</th>
<th>Floor</th>
<th style="width: 150px">Action</th>
</tr>
</thead>
<tbody>
<?php
$con=mysqli_connect("localhost","root","","klinik");
$per_page = 2;
$query = "SELECT COUNT(*) FROM poliknik";
$page_query = mysqli_query($con,$query);
$pages = ceil(mysqli_free_result($page_query, 0)/$per_page);
$page = (isset($_GET['hal'])) ? (int)$_GET['hal'] : 1;
$start = ($page - 1) * $per_page;
$data_kg=mysqli_query($con,"select * from poliknik order by id_poli DESC LIMIT $start,$per_page");
while ($kg=mysqli_fetch_object($data_kg)){
?>
<tr>
<td><?php echo $kg->kode?></td>
<td><?php echo $kg->name_poli?></td>
<td><?php echo $kg->lt?></td>
<td>
<a class="btn btn-primary btn-sm" href="home.php?p=edit_poliknik&id_poli=<?php echo $kg->id_poli ?>"><i class="fa fa-edit"></i> Edit</a>
<a class="btn btn-danger btn-sm" href="home.php?p=hapus_poliknik&id_poli=<?php echo $kg->id_poli ?>"><i class="fa fa-trash-o"></i> Delete</a>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<center>
<div>
<ul class="pagination pagination-lg pagination-colory">
<?php
if($pages >= 1 && $page <= $pages){
for($x=1; $x<=$pages; $x++){
echo ($x == $page) ? '<li class="active"><a href="home.php?p=poliknik&hal='.$x.'">'.$x.'</a></li>' : '<li><a href="home.php?p=poliknik&hal='.$x.'">'.$x.'</a></li>';
}
}
?>
</ul>
</div>
</center>
可以使用MySQL的>http://pastebin.com/CkyazRZM
錯誤/警告很明顯,不是嗎? – 2015-02-08 20:56:46
@ Fred-ii-顯然,錯誤消息需要修復代碼才能幫助他。 – 2015-02-08 20:59:21