In Php,while passing query string from page to another page how to do pagination.The following code I used it works fine for pagination without query string but while passing value from page to another page(Query String) it dint work.
Please give me any suggestions.

```
<?php
include("connect.php");
$adjacents = 3;
$id = $_REQUEST["id"];
$query = "SELECT COUNT(*) as num FROM data";
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];

$targetpage = "pagetest.php";
$limit = 10;
$page = $_GET['page'];
if($page)
    $start = ($page - 1) * $limit;
else
    $start = 0;

$sql = "SELECT name,email,dateins FROM data WHERE name='$id' LIMIT $start, $limit";
$result = mysql_query($sql);

$cnt=0;

                  if($result)
                  while($rs=mysql_fetch_assoc($result))
                  {
                  $cnt=$cnt+1;
                  $cssRow="class='gridRow'";
                  if(($cnt%2)==1)
                  {
                     $cssRow="class='gridRowAlternate'";
                  }

if ($page == 0) $page = 1;
$prev = $page - 1;                          
$next = $page + 1;                          
$lastpage = ceil($total_pages/$limit);      
$lpm1 = $lastpage - 1;                      

$pagination = "";
if($lastpage > 1)
{   
    $pagination .= "<div class=\"pagination\">";

    if ($page > 1) 
        $pagination.= "<a href=\"$targetpage?id=$id?page=$prev\">Previous</a>";
    else
        $pagination.= "<span class=\"disabled\">Previous</span>";   

    if ($lastpage < 7 + ($adjacents * 2))   
    {   
        for ($counter = 1; $counter <= $lastpage; $counter++)
        {
            if ($counter == $page)
                $pagination.= "<span class=\"current\">$counter</span>";
            else
                $pagination.= "<a href=\"$targetpage?id=$id?page=$counter\">$counter</a>";                  
        }
    }
    elseif($lastpage > 5 + ($adjacents * 2))    
    {
        if($page < 1 + ($adjacents * 2))        
        {
            for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
            {
                if ($counter == $page)
                    $pagination.= "<span class=\"current\">$counter</span>";
                else
                    $pagination.= "<a href=\"$targetpage?id=$id?page=$counter\">$counter</a>";                  
            }
            $pagination.= "...";
            $pagination.= "<a href=\"$targetpage?id=$id?page=$lpm1\">$lpm1</a>";
            $pagination.= "<a href=\"$targetpage?id=$id?page=$lastpage\">$lastpage</a>";        
        }
        elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
        {
            $pagination.= "<a href=\"$targetpage?id=$id?page=1\">1</a>";
            $pagination.= "<a href=\"$targetpage?id=$id?page=2\">2</a>";
            $pagination.= "...";
            for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
            {
                if ($counter == $page)
                    $pagination.= "<span class=\"current\">$counter</span>";
                else
                    $pagination.= "<a href=\"$targetpage?id=$id?page=$counter\">$counter</a>";                  
            }
            $pagination.= "...";
            $pagination.= "<a href=\"$targetpage?id=$id?page=$lpm1\">$lpm1</a>";
            $pagination.= "<a href=\"$targetpage?id=$id?page=$lastpage\">$lastpage</a>";        
        }
        else
        {
            $pagination.= "<a href=\"$targetpage?id=$id?page=1\">1</a>";
            $pagination.= "<a href=\"$targetpage?id=$id?page=2\">2</a>";
            $pagination.= "...";
            for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
            {
                if ($counter == $page)
                    $pagination.= "<span class=\"current\">$counter</span>";
                else
                    $pagination.= "<a href=\"$targetpage?id=$id?page=$counter\">$counter</a>";                  
            }
        }
    }

    //next button
    if ($page < $counter - 1) 
        $pagination.= "<a href=\"$targetpage?id=$id?page=$next\">Next</a>";
    else
        $pagination.= "<span class=\"disabled\">Next</span>";
    $pagination.= "</div>\n";
    }
    ?>
<tr>
<td><?php echo $rs['name']; ?></td>
<td><?php echo $rs['email']; ?></td>
<td><?php echo $rs['dateins']; ?></td>
</tr>
<?php
          }
          ?>
 <td><input type="hidden" name="id" id="id" value="<?php echo $id; ?>"></td>
 </table>
 <?php echo $pagination; ?>
 ?>

```

THANKS IN ADVANCE.