this code search all data not from current pagination page

<html>
<body>
<div id="content">
  <style>
.current {
padding: 2px 5px 2px 5px;
margin: 2px;
border: 1px solid #000099;
font-weight: bold;
background-color: #000099;
color: #FFF;
}
li {
display:inline-block
}
</style>
  <?php
include"connection.php";
$start=0;
$limit=5;
$id='';
if(isset($_GET['id']))
{
$id=$_GET['id'];
$start=($id-1)*$limit;
}

{
if(isset($_POST['Submit'])){
$query=mysql_query("select * from users where FirstName like '%$_REQUEST[fullname]%'");}
else{
$query=mysql_query("select * from users LIMIT $start, $limit");}
echo "<table border='1'>
<tr class='tableheader'>
<th>First Name</th>
<th>Last name</th>
<th>User Id</th>
<th>User Name</th>
<th>Password</th>
<th>Email</th>
<th>Created Date</th>
<th>Gender</th>
</tr>";
while($row=mysql_fetch_array($query))
{
echo "<tr class='tablerow'>";
echo "<td>" . $row['FirstName']      ."</td>";
echo "<td>" . $row['LastName']       ."</td>";
echo "<td>" . $row['UserID']     ."</td>";
echo "<td>" . $row['UserName']       ."</td>";
echo "<td>" . $row['Password']       ."</td>";
echo "<td>" . $row['Email']          ."</td>";
echo "<td>" . $row['CreatedDate']    ."</td>";
echo "<td>" . $row['Gender'] . "</td>";
echo "</tr>";    
}
echo "</table></div>";
$rows=mysql_num_rows(mysql_query("select * from users"));
$total=ceil($rows/$limit);
echo "<ul class='page'>";
for($i=1;$i<=$total;$i++)
{
if($i==$id) {
echo "<li class='current'>".$i."</li>"; }
else {
echo "<li><a href='?id=".$i."'>".$i."</a></li>"; }
}
echo "</ul>";

?>
  <form method="post" id="frm" name="frm" action="testa.php">
    <table width="500" border="0">
      <tr>
        <td>Search here:</td>
        <td><input type="text"  name="fullname" id="fullname"/></td>
        </tr>
        <tr>     
        <td><input type="submit" name="Submit" value="Search" /></td>
        <td>&nbsp;</td>
      </tr>

  </form>
  <form style="width:50%"  method="post" id="123" name="1234" >
  <tr>
        <td>Go To Page:</td>
    <td><input type="text" value=""  name="pagination" class=""/></td>
    </tr>
    <tr>
    <td><input name="insert" type="submit" class="button" value="go" /></td>
     </table>
  </form>
  <?php
if(isset($_POST['insert'])){
$Number     =$_POST['pagination'];
$Number=urlencode($Number);
header ("Location:http://localhost:1234/city/testa.php?id=$Number"); 
if ($Number >= $i){
header ("Location:http://localhost:1234/city/testa.php?id=1"); 
exit;
}


}}?>
</div>
</body>
</html>

Recommended Answers

All 2 Replies

Member Avatar for diafol

I suggest using the url querystring key of 'page' instead of 'id'. The use of 'id' is confusing.

If your url is something like this...

www.example.com/search.php?page=6

Then your code need only use the $_GET['page'] variable - if it's valid. Otherwise your 'page' value should be set to '1' (default value) or if the $_GET['page'] is an integer but greater than the max number of pages, set to the 'last page' (number of pages). This value could be stored as $page. Example:

<form action="search.php?page=<?php echo $page;?>" method="get">
    <label for="searchbox">Search:</label>
    <input name="search" id="searchbox" />
    <input type="submit" value="search" id="searchbutton" />
</form>

There are a number of ways of doing this.

please send the all code from this i am getting noting

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.