如何搜索用户名时只显示一个分页行?

如何搜索用户名时只显示一个分页行?

问题描述:

heys guys我是编程领域的初学者,所以我没有太多的经验。我有用户记录。当我在搜索框中搜索用户的名字,然后只有一个分页行显示我没问题检查这link of image如何搜索用户名时只显示一个分页行?

但是,当我删除搜索框中的用户名称,然后一个更多的分页行显示,我不希望它。我想只有一个分页网上搜索的用户名时,并删除的用户名检查这个link of image

在此先感谢

这是我的代码

<script> 
    function deleteConfirm(){ 
    var result = confirm("Are you sure to delete users?"); 
    if(result){ 
    return true; 
    } else 
     { 
     return false; 
    } 
    } 

    $(document).ready(function(){ 
    $('#select_all').on('click',function(){ 
    if(this.checked){ 
    $('.checkbox').each(function(){ 
     this.checked = true; 
     }); 
    }else{ 
     $('.checkbox').each(function(){ 
      this.checked = false; 
     }); 
    } 
    }); 

$('.checkbox').on('click',function(){ 
    if($('.checkbox:checked').length == $('.checkbox').length){ 
     $('#select_all').prop('checked',true); 
    }else{ 
     $('#select_all').prop('checked',false); 
    } 
}); 
}); 
    </script> 
    <?php 

    include("common/config.php"); 
    $output = ''; 

if(isset($_POST["query"])) 
    { 
    $search = $_POST["query"]; 


    $where = "id LIKE '%".$search."%' 
     OR name LIKE '%".$search."%' 
     OR email LIKE '%".$search."%' 
     OR phone LIKE '%".$search."%' "; 

$query = $db->select(array("*"),"user","$where","","id desc",""); 


} 
    else 
{ 
    $limit = 5; 

$page = ''; 
if (isset($_GET["page"])) 
    { 
    $page = $_GET["page"]; 
    } 
else 
    { 
    $page=1; 
    } 

    $record_index= ($page-1) * $limit; 

    $query = $db->select(array("*"),PREFIX."user", "", "", "id desc", "$record_index, $limit"); 
    } 

if($query) 
{ 

    $output .= ' 
    <div class="table-responsive"> 
    <form name="bulk_action_form" action="action.php" onSubmit="return 
    deleteConfirm();"/> 
    <table id="result" class="table table bordered"> 
<tr> 
<th style="text-align: center !important;"><input type="checkbox" name="select_all" id="select_all" value=""/></th> 
<th style="text-align: center !important;">ID</th> 
<th style="text-align: center !important;">Name</th> 
    <th style="text-align: center !important;">Email</th> 
    <th style="text-align: center !important;">Phone</th> 
    <th colspan="4" style="text-align: center !important;">Action</th> 
</tr>'; 

foreach($query as $row) 

{ 
    $output .= ' 
    <tr align="center"> 
    <td align="center"><input type="checkbox" name="checked_id[]" 
     class="checkbox" value="'.$row->id.'"/></td> 
    <td>'.$row->id.'</td> 
    <td>'.$row->name.'</td> 
    <td>'.$row->email.'</td> 
    <td>'.$row->phone.'</td> 
    <td><a href="edit-form.php?edit='.$row->id.'">Edit</a></td> 
    <td><a onclick="return confirm(\'Are you sure to delete?\')" href="del.php?del='.$row->id.'">Delete</a></td> 
    </tr>'; 
} 

    $output .= '</form></table><br /><div align="center">'; 
    $total_pages = ceil($db->countfields("*","user")/$limit); 
    for($i=1; $i<=$total_pages; $i++) 
{ 
    $output .= "<span class='pagination_link' style='cursor:pointer; padding:8px; border:1px solid #ccc;' id='".$i."'>".$i."</span>"; 
} 

    $output .= '</div><br /><br />'; 
    echo $output; 
} 

else 
{ 
    echo 'Data Not Found'; 
} 

?> 

这不只是第二形象是错误的。第一个只有1个结果,但仍然有4个页面。

看来,你有一些静态股利在您的HTML 4页。这可能是您发布的php代码下面的一些html,并且您忘记了删除。

从你发布的唯一解释。如果这不是你可以发布剩余的HTML代码?

+0

显示此页面的用户记录。没有其他的HTML代码被写入。 –

+0

必须有更多。您发布的图片中还有其他内容不在您发布的代码中。像那个分页输入和最后一个删除按钮一样。额外的分页div很可能就在输入之前。 – ZeWebDev