Thread: Paging Problem
View Single Post
Join Date: Jun 2007
Posts: 1,225
Reputation: kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about kkeith29 has a spectacular aura about 
Solved Threads: 166
kkeith29's Avatar
kkeith29 kkeith29 is offline Offline
Nearly a Posting Virtuoso

Re: Paging Problem

 
0
  #8
Sep 30th, 2007
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.

  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.
Reply With Quote