使用jquery在分页表中搜索记录

时间:2016-01-04 09:34:52

标签: php jquery

我想使用jquery在前端的表中搜索记录。该表是分页的。点击搜索按钮后,我想转到我在表格中记录的特定页面,并突出显示记录。

搜索Js:

$('#search').click(function(){ 
  var empno=$('#searchBox').val(); 
  ('table tr').each(function(){ 
    $(this).find('td').each(function(){ 
      employee=$(this).val(); 
      if( empno.indexOf(employee) >=0 ){ 
        $(this).closest('tr').css( "background-color", "orange" ); 
      } 
    )}; 
   )}; 
});

$sql1= " SELECT * from seat_alloc_dtl1 ";
$result1=$conn->query($sql1);
$per_page=10;
$total_results = $result1->num_rows;
$total_pages = ceil($total_results / $per_page);

if (isset($_GET["page"])) { $page  = $_GET["page"]; } else { $page=1; };
$start_from = ($page-1) * 10;
$sql= " SELECT * from seat_alloc_dtl1 LIMIT $start_from, 10 ";
$result=$conn->query($sql);
?>
<table id="emptable" border="1">
<tr><th style="width:160px;height:40px;text-align:center">Seat No</th ><th style="width:160px;height:40px;text-align:center">Category</th><th style="width:160px;height:40px;text-align:center">Status</th><th style="width:160px;height:40px;text-align:center">Allocated To</th><th style="width:160px;height:40px;text-align:center">Supervisor</th></tr>
<?php
while ($row = $result->fetch_assoc()) {
?>
<tr><td style="width:160px;height:40px;text-align:center"><?php echo $row['SeatNo'] ?></td><td style="width:160px;height:40px;text-align:center"><?php echo $row['Category'] ?></td><td style="width:160px;height:40px;text-align:center"><?php echo $row['Status'] ?></td><td style="width:160px;height:40px;text-align:center"><?php echo $row['AllocatedTo'] ?></td><td style="width:160px;height:40px;text-align:center"><?php echo $row['Supervisor'] ?></td></tr>

<?php
} 
}
?>
</table>
<?php for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='report.php?page=".$i."'>".$i."</a> ";
} ?>

0 个答案:

没有答案