Hi, here is the code for page navigation, its working fine but , if there are 4 pages , each page is displaying 3 records per page, if we go to 3rd page, and click on the subject it will display the contents but it will automatically come to the 1st page,,,,,,i dont want it to come to the first page. i want it to be remain in the same page where the user has clicked .......because i my code in half page i am showing records, if he click on some subject , in the second half of the page it is displaying contents as soon as he clicks.....so if he goes to 4th page and clicks on some subject it will show the contents but the first half portion of the page where i am displaying the records will automatically go to first page,,,,,,,,,,the second part will remain same......so help me out
First part of the page to display the records.
<?
session_start();
include('database.php');
$page_name="contractor_inbox.php";
//$limit=sql_quote($_GET['limit']); // Read the limit value from query string.
$limit=$_GET['limit'];
//$start=sql_quote($_GET['start']); // To take care global variable if OFF
$start=$_GET['start'];
if(!($start > 0))
{ // This variable is set to zero for the first page
$start = 0;
}
$eu = ($start - 0);
if(!$limit > 0 )
{ // if limit value is not available then let us use a default value
$limit = 3; // No of records to be shown per page by default.
}
$this1 = $eu + $limit;
$back = $eu - $limit;
$next = $eu + $limit;
//*****************************************************************/
$result = mysql_query("SELECT * FROM autoalto_mail limit $eu, $limit" );
//code for paging
//**************************************************************************
$selcount = "SELECT * FROM autoalto_mail" ;
$result2=mysql_query($selcount);
$nume=mysql_num_rows($result2);
echo $nume;
//echo "<table>";
//**************************************************************************
while($row = mysql_fetch_array($result))
{?>
<tr><td width="5%"></td>
<td><? echo $row['From_user'];?></td>
<td><a href="contractor_inbox.php?mail_id=<? echo $row['mail_id'];
//session_register("mail_id");
?>">
<?echo $row['subject'];
$subj=$row['subject'];
session_register("subj");?> </a></td>
<td><?echo $row['date'];?></td>
</tr>
<tr><td width="5%"></td>
<td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td></tr>
<?
}?>
</table>
<?
if($nume > $limit)
{
//Counting no of pages and the current page.
$totnumofpages = round($nume/$limit);
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit)
{
if($i == $eu)
{
$currentpage= $l;
}
$l=$l+1;
}
echo "<div height=28 align=right><table cellpadding=3 cellspacing=1 border=0 height=28><tr><td>Page ".$currentpage." / ".$totnumofpages."</td>";
//// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
if($back >=0)
{
print "<td align='left'><a href='$page_name?start=$back&limit=$limit'><</a></td>";
}
//////////////// We will not display the current page as a link ///////////
$i=0;
$l=1;
for($i=0;$i < $nume;$i=$i+$limit)
{
if($i <> $eu)
{
echo "<td align=center><a href='$page_name?start=$i&limit=$limit'><span>$l</span></a></td>";
}
else
{
echo "<td align=center><span><b>$l</b></span></td>";
} /// Current page is not displayed as link
$l=$l+1;
}
///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
if($this1 < $nume)
{
print "<td align=center width=15><a href='$page_name?start=$next&limit=$limit'><span ><b>></b></span></a></td>";
}
echo "</tr></table></div>";
}
mysql_close();
?>
second part to show the contents
<table border="0" cellpadding="0" cellspacing="0" align="center" width="100%" style="border:1px solid #EDEDED;background-color:#ffffff">
<tr><td><b><font size="2"><span style="color:005D95">Subject:</span></b>
<?
session_start();
include('database.php');
$mailid1 = $_GET['mail_id'];
session_register("mailid1");
$query1="SELECT * FROM autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
while($row = mysql_fetch_array($result))
{
echo $row['subject'];
}
mysql_close();
?>
</b></td>
<td align="right" colspan="3" style="padding-left:5px;" class="headtitle">
<a href="Contractor_reply.php"><b>Reply</b></a><span >/</span>
<a href="contactor_inbox_delete.php"><b>Delete</b></a><span>/</span>
<a href="lll.html"><b>Next</b></a></td></tr>
<tr><td><b><font size="2"><span style="color:005D95">From:</span></b>
<?
session_start();
include('database.php');
$mailid1 = $_GET['mail_id'];
$query1="SELECT * FROM autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
while($row = mysql_fetch_array($result))
{
echo $row['From_user'];
}
mysql_close();
?>
</b></td></tr>
</table>
</td></tr>
<tr><td>
<?
session_start();
include('database.php');
$mailid1 = $_GET['mail_id'];
echo $_GET['mail_id'];
$query1="SELECT * FROM autoalto_mail where mail_id='".$mailid1."'";
$result = mysql_query( $query1 );
//echo mysql_num_rows($result) ;
while($row = mysql_fetch_array($result))
{
echo $row['contents'];
}
mysql_close();
?>