943,721 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 3548
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Sep 25th, 2007
0

Paging Problem

Expand Post »
Hello everybody,
I found paging code from www.plus2net.com, but when I implemented there is a problem with $this variable and the error is:
"Fatal error: Cannot re-assign $this in C:\wamp\www\Paging\php_paging.php on line 33"

This is the code:
PHP Syntax (Toggle Plain Text)
  1. <?php
  2. //****************************************************************************
  3. ////////////////////////Downloaded from www.plus2net.com //////////////////////////////////////////
  4. /////////////////////// Visit www.plus2net.com for more such script and codes.
  5. //////// Read the readme file before using /////////////////////
  6. //////////////////////// You can distribute this code with the link to www.plus2net.com ///
  7. ///////////////////////// Please don't remove the link to www.plus2net.com ///
  8. //////////////////////////
  9. //*****************************************************************************
  10. ?>
  11. <!doctype html public "-//w3c//dtd html 3.2//en">
  12.  
  13. <html>
  14.  
  15. <head>
  16. <title>Plus2net.com paging script in PHP</title>
  17. <meta name="GENERATOR" content="Arachnophilia 4.0">
  18. <meta name="FORMATTER" content="Arachnophilia 4.0">
  19. </head>
  20.  
  21. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  22. <?php
  23. require "config.php"; // All database details will be included here
  24.  
  25. $page_name="php_paging.php"; // If you use this code with a different page ( or file ) name then change this
  26.  
  27. if(!isset($start)) { // This variable is set to zero for the first page
  28. $start = 0;
  29. }
  30.  
  31. $eu = ($start -0);
  32. $limit = 2; // No of records to be shown per page.
  33. $this = $eu + $limit;
  34. $back = $eu - $limit;
  35. $next = $eu + $limit;
  36.  
  37.  
  38. /////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
  39. $query2=" SELECT * FROM student_adv ";
  40. $result2=mysql_query($query2);
  41. echo mysql_error();
  42. $nume=mysql_num_rows($result2);
  43. /////// The variable nume above will store the total number of records in the table////
  44.  
  45. /////////// Now let us print the table headers ////////////////
  46. $bgcolor="#f1f1f1";
  47. echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
  48. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>ID</font></td>";
  49.  
  50. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
  51. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
  52. echo "<td bgcolor='dfdfdf'>&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Mark</font></td></tr>";
  53.  
  54. ////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
  55. $query=" SELECT * FROM student_adv limit $eu, $limit ";
  56. $result=mysql_query($query);
  57. echo mysql_error();
  58.  
  59. //////////////// Now we will display the returned records in side the rows of the table/////////
  60. while($noticia = mysql_fetch_array($result))
  61. {
  62. if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
  63. else{$bgcolor='#f1f1f1';}
  64.  
  65. echo "<tr >";
  66. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[id]</font></td>";
  67.  
  68. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[name]</font></td>";
  69. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[class]</font></td>";
  70. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[mark]</font></td>";
  71.  
  72. echo "</tr>";
  73. }
  74. echo "</table>";
  75. ////////////////////////////// End of displaying the table with records ////////////////////////
  76.  
  77. ///// Variables set for advance paging///////////
  78. $p_limit=8; // This should be more than $limit and set to a value for whick links to be breaked
  79. if(!isset($p_f)){$p_f=0;}
  80. $p_fwd=$p_f+$p_limit;
  81. $p_back=$p_f-$p_limit;
  82. //////////// End of variables for advance paging ///////////////
  83. /////////////// Start the buttom links with Prev and next link with page numbers /////////////////
  84. echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>";
  85. if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; }
  86. echo "</td><td align='left' width='10%'>";
  87. //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
  88. if($back >=0 and ($back >=$p_f)) {
  89. print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>";
  90. }
  91. //////////////// Let us display the page links at center. We will not display the current page as a link ///////////
  92. echo "</td><td align=center width='30%'>";
  93. for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
  94. if($i <> $eu){
  95. $i2=$i+$p_f;
  96. echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> ";
  97. }
  98. else { echo "<font face='Verdana' size='4' color=red>$i</font>";} /// Current page is not displayed as link and given font color red
  99.  
  100. }
  101.  
  102.  
  103. echo "</td><td align='right' width='10%'>";
  104. ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
  105. if($this < $nume and $this <($p_f+$p_limit)) {
  106. print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";}
  107. echo "</td><td align='right' width='20%'>";
  108. if($p_fwd < $nume){
  109. print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>";
  110. }
  111. echo "</td></tr></table>";
  112.  
  113.  
  114. ?>
  115. <center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center>
  116. </body>
  117.  
  118. </html>
Similar Threads
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Sep 25th, 2007
0

Re: Paging Problem

It's because $this is a reserved word used with classes to reference the current object. For example

php Syntax (Toggle Plain Text)
  1. class TestClass
  2. {
  3. var $blah;
  4. function setBlah($input)
  5. {
  6. $this->blah = $input;
  7. }
  8. }
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Sep 26th, 2007
0

Re: Paging Problem

thnx for that,
so what should I do? How should I do paging withing PHP, if possible plz descibe me more...
Last edited by tanha; Sep 26th, 2007 at 5:08 am.
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Sep 26th, 2007
0

Re: Paging Problem

try this:

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. //****************************************************************************
  3. ////////////////////////Downloaded from www.plus2net.com //////////////////////////////////////////
  4. /////////////////////// Visit www.plus2net.com for more such script and codes.
  5. //////// Read the readme file before using /////////////////////
  6. //////////////////////// You can distribute this code with the link to www.plus2net.com ///
  7. ///////////////////////// Please don't remove the link to www.plus2net.com ///
  8. //////////////////////////
  9. //*****************************************************************************
  10. ?>
  11. <!doctype html public "-//w3c//dtd html 3.2//en">
  12.  
  13. <html>
  14.  
  15. <head>
  16. <title>Plus2net.com paging script in PHP</title>
  17. <meta name="GENERATOR" content="Arachnophilia 4.0">
  18. <meta name="FORMATTER" content="Arachnophilia 4.0">
  19. </head>
  20.  
  21. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  22. <?php
  23. require "config.php"; // All database details will be included here
  24.  
  25. $page_name="php_paging.php"; // If you use this code with a different page ( or file ) name then change this
  26.  
  27. if(!isset($start)) { // This variable is set to zero for the first page
  28. $start = 0;
  29. }
  30.  
  31. $eu = ($start -0);
  32. $limit = 2; // No of records to be shown per page.
  33. $p = $eu + $limit;
  34. $back = $eu - $limit;
  35. $next = $eu + $limit;
  36.  
  37.  
  38. /////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
  39. $query2=" SELECT * FROM student_adv ";
  40. $result2=mysql_query($query2);
  41. echo mysql_error();
  42. $nume=mysql_num_rows($result2);
  43. /////// The variable nume above will store the total number of records in the table////
  44.  
  45. /////////// Now let us print the table headers ////////////////
  46. $bgcolor="#f1f1f1";
  47. echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
  48. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>ID</font></td>";
  49.  
  50. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
  51. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
  52. echo "<td bgcolor='dfdfdf'>&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Mark</font></td></tr>";
  53.  
  54. ////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
  55. $query=" SELECT * FROM student_adv limit $eu, $limit ";
  56. $result=mysql_query($query);
  57. echo mysql_error();
  58.  
  59. //////////////// Now we will display the returned records in side the rows of the table/////////
  60. while($noticia = mysql_fetch_array($result))
  61. {
  62. if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
  63. else{$bgcolor='#f1f1f1';}
  64.  
  65. echo "<tr >";
  66. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[id]</font></td>";
  67.  
  68. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[name]</font></td>";
  69. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[class]</font></td>";
  70. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[mark]</font></td>";
  71.  
  72. echo "</tr>";
  73. }
  74. echo "</table>";
  75. ////////////////////////////// End of displaying the table with records ////////////////////////
  76.  
  77. ///// Variables set for advance paging///////////
  78. $p_limit=8; // This should be more than $limit and set to a value for whick links to be breaked
  79. if(!isset($p_f)){$p_f=0;}
  80. $p_fwd=$p_f+$p_limit;
  81. $p_back=$p_f-$p_limit;
  82. //////////// End of variables for advance paging ///////////////
  83. /////////////// Start the buttom links with Prev and next link with page numbers /////////////////
  84. echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>";
  85. if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; }
  86. echo "</td><td align='left' width='10%'>";
  87. //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
  88. if($back >=0 and ($back >=$p_f)) {
  89. print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>";
  90. }
  91. //////////////// Let us display the page links at center. We will not display the current page as a link ///////////
  92. echo "</td><td align=center width='30%'>";
  93. for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
  94. if($i <> $eu){
  95. $i2=$i+$p_f;
  96. echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> ";
  97. }
  98. else { echo "<font face='Verdana' size='4' color=red>$i</font>";} /// Current page is not displayed as link and given font color red
  99.  
  100. }
  101.  
  102.  
  103. echo "</td><td align='right' width='10%'>";
  104. ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
  105. if($p < $nume and $p <($p_f+$p_limit)) {
  106. print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";}
  107. echo "</td><td align='right' width='20%'>";
  108. if($p_fwd < $nume){
  109. print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>";
  110. }
  111. echo "</td></tr></table>";
  112.  
  113.  
  114. ?>
  115. <center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center>
  116. </body>
  117.  
  118. </html>
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 30th, 2007
0

Re: Paging Problem

Thaks for the code,
There is no error on the code now, but when I click on the link navigation (1 2 3 4 next) nothing happen, doesnot go to the page I want...
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Sep 30th, 2007
0

Re: Paging Problem

hover over link and see what the url is of it. once you do this post it here and maybe i'll figure it out
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 30th, 2007
0

Re: Paging Problem

hi.
1. First I open it, I just see the Link Navigation the even numbers mean (0 2 4 6 8 Next Next8)
2. When I click on any of the navigation link, I see the address bar like below:
php_pagin.php?start=2&p_f=0
php_pagin.php?start=4&p_f=0
php_pagin.php?start=6&p_f=0
php_pagin.php?start=8&p_f=0

means just in the address bar the number changes, nothing else happens in the page
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Sep 30th, 2007
0

Re: Paging Problem

i looked over the entire code line by line and really didn't see anything wrong. i took out all of the comments and stuff so i could read it better, made a few changes. i think it might work.

PHP Syntax (Toggle Plain Text)
  1. <!doctype html public "-//w3c//dtd html 3.2//en">
  2. <html>
  3. <head>
  4. <title>Plus2net.com paging script in PHP</title>
  5. </head>
  6. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  7. <?php
  8. require "config.php";
  9. $page_name="php_paging.php";
  10. if(!isset($start)) {
  11. $start = 0;
  12. }
  13.  
  14. $eu = ($start -0);
  15. $limit = 2;
  16. $this_page = $eu + $limit;
  17. $back = $eu - $limit;
  18. $next = $eu + $limit;
  19. $query2=" SELECT * FROM student_adv ";
  20. $result2=mysql_query($query2);
  21. echo mysql_error();
  22. $nume=mysql_num_rows($result2);
  23. $bgcolor="#f1f1f1";
  24. echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
  25. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>ID</font></td>";
  26. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
  27. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
  28. echo "<td bgcolor='dfdfdf'>&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Mark</font></td></tr>";
  29. $query=" SELECT * FROM student_adv limit $eu, $limit ";
  30. $result=mysql_query($query);
  31. echo mysql_error();
  32. while($noticia = mysql_fetch_array($result))
  33. {
  34. if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
  35. else{$bgcolor='#f1f1f1';}
  36. echo "<tr >";
  37. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[id]</font></td>";
  38. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[name]</font></td>";
  39. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[class]</font></td>";
  40. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[mark]</font></td>";
  41. echo "</tr>";
  42. }
  43. echo "</table>";
  44. $p_limit=8;
  45. if(!isset($p_f)){$p_f=0;}
  46. $p_fwd=$p_f+$p_limit;
  47. $p_back=$p_f-$p_limit;
  48. echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>";
  49. if($p_f=0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; }
  50. echo "</td><td align='left' width='10%'>";
  51. if($back >=0 && ($back >=$p_f)) {
  52. print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>";
  53. }
  54. echo "</td><td align=center width='30%'>";
  55. for($i=$p_f;$i < $nume && $i<($p_f+$p_limit);$i=$i+$limit){
  56. if($i = $eu){
  57. $i2=$i+$p_f;
  58. echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> ";
  59. }
  60. else { echo "<font face='Verdana' size='4' color=red>$i</font>";}
  61. }
  62. echo "</td><td align='right' width='10%'>";
  63. if($this_page < $nume && $this_page <($p_f+$p_limit)) {
  64. print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";}
  65. echo "</td><td align='right' width='20%'>";
  66. if($p_fwd < $nume){
  67. print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>";
  68. }
  69. echo "</td></tr></table>";
  70. ?>
  71. </body>
  72. </html>

if it doesn't work i will probably make my own script that does work.
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007
Sep 30th, 2007
0

Re: Paging Problem

Really thanks for ur reply,
I used the code, but the system is not able to load the navigation part...I mean it is trying to load something in the page but not able...

If possible plz send me your own script, with comments coz I want to get fimiliar too, that would be very kind of you... Thanks
Last edited by tanha; Sep 30th, 2007 at 5:59 am.
Reputation Points: 8
Solved Threads: 1
Posting Whiz in Training
tanha is offline Offline
217 posts
since Aug 2007
Sep 30th, 2007
0

Re: Paging Problem

i set up a database to check the code and i think i fixed the problem.

PHP Syntax (Toggle Plain Text)
  1. <?php
  2. //****************************************************************************
  3. ////////////////////////Downloaded from www.plus2net.com //////////////////////////////////////////
  4. /////////////////////// Visit www.plus2net.com for more such script and codes.
  5. //////// Read the readme file before using /////////////////////
  6. //////////////////////// You can distribute this code with the link to www.plus2net.com ///
  7. ///////////////////////// Please don't remove the link to www.plus2net.com ///
  8. //////////////////////////
  9. //*****************************************************************************
  10. ?>
  11. <!doctype html public "-//w3c//dtd html 3.2//en">
  12.  
  13. <html>
  14.  
  15. <head>
  16. <title>Plus2net.com paging script in PHP</title>
  17. <meta name="GENERATOR" content="Arachnophilia 4.0">
  18. <meta name="FORMATTER" content="Arachnophilia 4.0">
  19. </head>
  20.  
  21. <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
  22. <?php
  23. require "mysql.php"; // All database details will be included here
  24.  
  25. $page_name="paging.php"; // If you use this code with a different page ( or file ) name then change this
  26.  
  27. if(!isset($start)) { // This variable is set to zero for the first page
  28. $start = 0;
  29. }
  30.  
  31. $eu = ($start -0);
  32. $limit = 1; // No of records to be shown per page.
  33. $this = $eu;
  34. $number = 2;
  35. $back = $eu - $limit;
  36. $next = $eu + $limit;
  37.  
  38.  
  39. /////////////// WE have to find out the number of records in our table. We will use this to break the pages///////
  40. $query2=" SELECT * FROM student_adv ";
  41. $result2=mysql_query($query2);
  42. echo mysql_error();
  43. $nume=mysql_num_rows($result2);
  44. /////// The variable nume above will store the total number of records in the table////
  45.  
  46. /////////// Now let us print the table headers ////////////////
  47. $bgcolor="#f1f1f1";
  48. echo "<TABLE width=50% align=center cellpadding=0 cellspacing=0> <tr>";
  49. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>ID</font></td>";
  50.  
  51. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Name</font></td>";
  52. echo "<td bgcolor='dfdfdf' >&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Class</font></td>";
  53. echo "<td bgcolor='dfdfdf'>&nbsp;<font face='arial,verdana,helvetica' color='#000000' size='4'>Mark</font></td></tr>";
  54.  
  55. ////////////// Now let us start executing the query with variables $eu and $limit set at the top of the page///////////
  56. $query=" SELECT * FROM student_adv limit $eu, $number ";
  57. $result=mysql_query($query);
  58. echo mysql_error();
  59.  
  60. //////////////// Now we will display the returned records in side the rows of the table/////////
  61. while($noticia = mysql_fetch_array($result))
  62. {
  63. if($bgcolor=='#f1f1f1'){$bgcolor='#ffffff';}
  64. else{$bgcolor='#f1f1f1';}
  65.  
  66. echo "<tr >";
  67. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[id]</font></td>";
  68.  
  69. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[name]</font></td>";
  70. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[class]</font></td>";
  71. echo "<td align=left bgcolor=$bgcolor id='title'>&nbsp;<font face='Verdana' size='2'>$noticia[mark]</font></td>";
  72.  
  73. echo "</tr>";
  74. }
  75. echo "</table>";
  76. ////////////////////////////// End of displaying the table with records ////////////////////////
  77.  
  78. ///// Variables set for advance paging///////////
  79. $p_limit=8; // This should be more than $limit and set to a value for whick links to be breaked
  80. if(!isset($p_f)){$p_f=0;}
  81. $p_fwd=$p_f+$p_limit;
  82. $p_back=$p_f-$p_limit;
  83. //////////// End of variables for advance paging ///////////////
  84. /////////////// Start the buttom links with Prev and next link with page numbers /////////////////
  85. echo "<table align = 'center' width='50%'><tr><td align='left' width='20%'>";
  86. if($p_f<>0){print "<a href='$page_name?start=$p_back&p_f=$p_back'><font face='Verdana' size='2'>PREV $p_limit</font></a>"; }
  87. echo "</td><td align='left' width='10%'>";
  88. //// if our variable $back is equal to 0 or more then only we will display the link to move back ////////
  89. if($back >=0 and ($back >=$p_f)) {
  90. print "<a href='$page_name?start=$back&p_f=$p_f'><font face='Verdana' size='2'>PREV</font></a>";
  91. }
  92. //////////////// Let us display the page links at center. We will not display the current page as a link ///////////
  93. echo "</td><td align=center width='30%'>";
  94. for($i=$p_f;$i < $nume and $i<($p_f+$p_limit);$i=$i+$limit){
  95. if($i <> $eu){
  96. $i2=$i+$p_f;
  97. echo " <a href='$page_name?start=$i&p_f=$p_f'><font face='Verdana' size='2'>$i</font></a> ";
  98. }
  99. else { echo "<font face='Verdana' size='4' color=red>$i</font>";} /// Current page is not displayed as link and given font color red
  100.  
  101. }
  102.  
  103.  
  104. echo "</td><td align='right' width='10%'>";
  105. ///////////// If we are not in the last page then Next link will be displayed. Here we check that /////
  106. if($this < $nume and $this <($p_f+$p_limit)) {
  107. print "<a href='$page_name?start=$next&p_f=$p_f'><font face='Verdana' size='2'>NEXT</font></a>";}
  108. echo "</td><td align='right' width='20%'>";
  109. if($p_fwd < $nume){
  110. print "<a href='$page_name?start=$p_fwd&p_f=$p_fwd'><font face='Verdana' size='2'>NEXT $p_limit</font></a>";
  111. }
  112. echo "</td></tr></table>";
  113.  
  114.  
  115. ?>
  116. <center><a href='http://www.plus2net.com'>PHP SQL HTML free tutorials and scripts</a></center>
  117. </body>
  118.  
  119. </html>
Reputation Points: 235
Solved Threads: 193
Nearly a Posting Virtuoso
kkeith29 is offline Offline
1,315 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Getting mysql "UNaffected" rows
Next Thread in PHP Forum Timeline: Need Help with converting an ID to a Name





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC