Problem...in page navigation

Thread Solved

Join Date: Jun 2008
Posts: 142
Reputation: ishlux is an unknown quantity at this point 
Solved Threads: 0
ishlux ishlux is offline Offline
Junior Poster

Problem...in page navigation

 
0
  #1
Jul 30th, 2008
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
here is the code..
  1. <?
  2. session_start();
  3. include('database.php');
  4. $page_name="contractor_inbox.php";
  5. //$limit=sql_quote($_GET['limit']); // Read the limit value from query string.
  6. $limit=$_GET['limit'];
  7. //$start=sql_quote($_GET['start']); // To take care global variable if OFF
  8. $start=$_GET['start'];
  9. if(!($start > 0))
  10. { // This variable is set to zero for the first page
  11. $start = 0;
  12. }
  13.  
  14. $eu = ($start - 0);
  15. if(!$limit > 0 )
  16. { // if limit value is not available then let us use a default value
  17. $limit = 4; // No of records to be shown per page by default.
  18. }
  19. $this1 = $eu + $limit;
  20. $back = $eu - $limit;
  21. $next = $eu + $limit;
  22. //*****************************************************************/
  23. $result = mysql_query("SELECT * FROM autoalto_mail where flag!='1' limit $eu, $limit" );
  24.  
  25. //code for paging
  26. //**************************************************************************
  27. $selcount = "SELECT * FROM autoalto_mail ORDER BY primarykey column name DESC" ;
  28. $selcount = "SELECT * FROM autoalto_mail where flag!='1'" ;
  29. $result2=mysql_query($selcount);
  30. $nume=mysql_num_rows($result2);
  31. //echo $nume;
  32. //session_register("nume");
  33. //$nume = $_SESSION['nume'];
  34. //session_register("nume");
  35. $_SESSION['nume']=$nume;
  36.  
  37. //echo "<table>";
  38. //**************************************************************************
  39. while($row = mysql_fetch_array($result))
  40. {?>
  41. <tr class="sectiontableentry2" ><!--<td width="5%"></td>-->
  42. <td><? echo $row['From_user'];?></td>
  43. <td><a href="contractor_inbox.php?mail_id=<? echo $row['mail_id'];
  44. //session_register("mail_id");
  45. //session_register("mail_id");
  46. ?>">
  47. <?echo $row['subject'];
  48. $subj=$row['subject'];
  49. session_register("subj");?> </a></td>
  50. <td><?echo $row['date'];?></td>
  51. </tr>
  52. <!--<tr class="sectiontableentry1"></tr>
  53.  
  54. <!--<tr class="sectiontableentry1"><td width="5%"></td>
  55. <td colspan="4" style="background-repeat: repeat-x;" background="images/dot.jpg" height="0" width="300"></td></tr>-->
  56. <?
  57. }?>
  58. </table>
  59. <?
  60. if($nume > $limit)
  61. {
  62. //Counting no of pages and the current page.
  63. $totnumofpages = round($nume/$limit);
  64. $i=0;
  65. $l=1;
  66. for($i=0;$i < $nume;$i=$i+$limit)
  67. {
  68. if($i == $eu)
  69. {
  70. $currentpage= $l;
  71. }
  72. $l=$l+1;
  73. }
  74.  
  75. echo "<div height=28 align=right><table cellpadding=3 cellspacing=1 border=0 height=28><tr><td>Page ".$currentpage." / ".$totnumofpages."</td>";
  76. //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
  77. if($back >=0)
  78. {
  79. print "<td align='left'><a href='$page_name?start=$back&limit=$limit'>&lt;</a></td>";
  80. }
  81. //////////////// We will not display the current page as a link ///////////
  82. $i=0;
  83. $l=1;
  84. for($i=0;$i < $nume;$i=$i+$limit)
  85. {
  86. if($i <> $eu)
  87. {
  88. echo "<td align=center><a href='$page_name?start=$i&limit=$limit'><span>$l</span></a></td>";
  89. }
  90. else
  91. {
  92. echo "<td align=center><span><b>$l</b></span></td>";
  93. } /// Current page is not displayed as link
  94. $l=$l+1;
  95. }
  96. ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
  97. if($this1 < $nume)
  98. {
  99. print "<td align=center width=15><a href='$page_name?start=$next&limit=$limit'><span ><b>&gt;</b></span></a></td>";
  100. }
  101. echo "</tr></table></div>";
  102. }
  103. mysql_close();
  104. ?>
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Problem...in page navigation

 
0
  #2
Jul 30th, 2008
Hi,

Modify the following line.
  1. <a href="contractor_inbox.php?mail_id=<? echo $row['mail_id'];//session_register("mail_id");//session_register("mail_id");?>">

with

  1. ><a href="contractor_inbox.php?start=$start&limit=$limit&mail_id=<? echo $row['mail_id'];
  2. //session_register("mail_id");//session_register("mail_id");?>">
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 133
Reputation: vicky_rawat is an unknown quantity at this point 
Solved Threads: 17
vicky_rawat's Avatar
vicky_rawat vicky_rawat is offline Offline
Junior Poster

Re: Problem...in page navigation

 
0
  #3
Jul 30th, 2008
Ohh sorry, use this.

  1. <a href="contractor_inbox.php?start=<?=$start?>&limit=<?=$limit?>&mail_id=<?=$row['mail_id'];?>">
Vivek Rawat
Keep solving complexities.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC