2017-05-29 84 views
1

你好,我是新手在PHP和學習如何使用搜索和分頁使用List.Js和php 我有問題得到list.js工作,搜索和篩選查詢結果在PHP中。我已經在文檔中遵循示例,但仍然沒有運氣。 這裏我的代碼:搜索和分頁sql查詢php

<div class="box-body"> 

<div id="listperson" align="center"> 
    <input type="text" placeholder="Search" class="fuzzy-search"/> 
<table class="col-md-12"> 
    <thead> 
     <tr> 
      <th class="col-md-1 sort"></th> 
      <th class="col-md-3 sort" data-sort="nama">Name</th> 
      <th class="col-md-1 sort" data-sort="role">Role</th> 
      <th class="col-md-3 sort">Email</th> 
      <th class="col-sm-2 sort">No.Hp</th> 
      <th class="col-sm-3 sort" data-sort="alamat">Alamat</th> 
      <th class="col-sm-1 sort">Edit</th> 
      <th class="col-sm-1 sort">Delete</th> 
     </tr> 
    </thead> 
    <?php 
     $peoplequery=mysqli_query($CONN,"SELECT * FROM people"); 
     while($people=mysqli_fetch_array($peoplequery)){ 
     ?> 
    <tbody class="list">    
     <tr align="left"> 
      <td class="img"> 
      <img src="../img/man-128.png" class="direct-chat-img" width="10px" height="10px"> 
      </td> 
      <td class="name"><a href="personview.php?PersonID=<?= $people['idpeople'] ?>"><?php echo $people['namadepan'] . ' ' .$people['namabelakang']; ?></a></td> 
      <td class="role"><?php echo $people['role']; ?></td> 
      <td class="email"><?php echo $people['email']; ?></td> 
      <td class="nohp"><?php echo $people['nohp']; ?></td> 
      <td class="alamat"><?php echo $people['alamat']; ?></td>     
      <td class="edit" align="center"> 
      <a href="editperson.php?PersonID=<?= $people['idpeople'] ?>"> 
      <span class="fa-stack"> 
      <i class="fa fa-square fa-stack-2x"></i> 
      <i class="fa fa-pencil fa-stack-1x fa-inverse"></i> 
      </span> 
      </a> 
      </td> 
      <td class="delete" align="center"> 
      <a href="deleteperson.php?PersonID=<?= $people['idpeople'] ?>"> 
      <span class="fa-stack" style="color:#ff0000; "> 
      <i class="fa fa-square fa-stack-2x"></i> 
      <i class="fa fa-trash fa-stack-1x fa-inverse" ></i> 
      </span> 
      </a> 
      </td>    
     </tr> 
     <?php 
     $idppl = $people['idpeople']; 
     } ?> 
    </tbody> 
</table> 
<ul class="pagination"></ul> 
</div> 
<script src="//cdnjs.cloudflare.com/ajax/libs/list.js/1.1.1/list.min.js"> 
</script> 
<script type="text/javascript"> 
var options = { 
    valueNames: [ 'name', 'role', 'email'], 
    page: 5, 
    plugins: [ 
    ListPagination({}) 
] 

}; 
var contactList = new List('listperson', options); 
</script> 

</div> 

分頁沒有顯示和搜索還沒有工作。我不知道我在這裏失蹤 任何幫助讚賞謝謝。

回答

0

您的開頭<tbody>標記位於您的while循環內,但您的關閉</tbody>標記位於該循環之外。

這可能意味着您的表格格式不正確。這可能使List.js混淆。

使用View Source...檢查HTML是否正確生成總是很好。

+0

感謝分頁工作。但搜索結果是現在返回錯誤的數據,並在視圖源中顯示沒有任何錯誤。 –

+0

您無需在查看源代碼中查找錯誤。相反,你正在尋找你傳遞給javascript的表的結構。您正在查看它是否具有您期望的格式。 –