Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> księga gości, wadliwe działanie
golden
post
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 7.01.2005

Ostrzeżenie: (0%)
-----


Witam. Mam problem z księgą gości, a mianowicie niepoprawnie działa przełączanie między kolejnymi stronami.
  1. <?php
  2.  
  3. $link = mysql_connect(&#092;"localhost\", \"user\", \"password\");
  4.  
  5. mysql_select_db(&#092;"db\",$link);
  6.  
  7. $result = mysql_query(&#092;"SELECT * FROM ksiega\"); 
  8. $num_rows = mysql_num_rows($result);
  9.  
  10.  
  11. if ($num_rows < 30)
  12.  $stop = $num_rows;
  13. else if ($num_rows > 30 && (($num_rows - $id ) < 30))
  14.  $stop = $num_rows - $id;
  15. else
  16.  $stop = 30;
  17.  
  18.  
  19.  
  20. for ($n = $stop - 1; $n >= 0; $n--) {
  21.  
  22.  $tmp = $id + $n;
  23.  
  24.  $sql=mysql_query(&#092;"SELECT * FROM ksiega WHERE id='$tmp'\");
  25. $tab=mysql_fetch_row($sql);
  26.  
  27.  echo &#092;"
  28. <table width=&#092;"420\" border=\"1\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
  29. <tr>
  30. <td width=&#092;"210\"><div align=\"left\"><a href=\"mailto:$tab[5]\" class=\"linki\">$tab[1]</a></div></td>
  31. <td width=&#092;"210\"><div align=\"right\">$tab[7]</div></td>
  32. </tr>
  33. <tr>
  34. <td colspan=&#092;"2\"><div align=\"left\">$tab[2]</div></td>
  35. </tr>
  36. <tr>
  37. <td colspan=&#092;"2\"><div align=\"left\">GG: $tab[4]</div></td>
  38. </tr>
  39. <tr>
  40. <td colspan=&#092;"2\"><div align=\"left\">Http://<a href=\"$tab[3]\" target=\"_blank\" class=\"linki\">$tab[3]</a></div></td>
  41. </tr>
  42. </table>
  43. <hr>  
  44.  &#092;"; 
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55. $id+=30;
  56. if ($num_rows > 30 && $id < 30) {
  57. echo &#092;"<a href=\"ksiega.php?id=$id\" class=\"linki\"> następne &gt;&gt; </a></center>\";
  58. } else if ($num_rows < 30) {
  59.  
  60. } else if (($num_rows - $id) > 30) {
  61.  $id -= 31;
  62. echo &#092;"<center><a href=\"ksiega.php?id=$id\" class=\"linki\"> &lt;&lt; poprzednie </a> \";
  63.  $id += 31;
  64. echo &#092;"<a href=\"ksiega.php?id=$id\" class=\"linki\"> &lt;&lt; poprzednie </a></center>\";
  65. } else if (($num_rows - $id) < 30 && $num_rows > 30) {
  66.  $id -= 31;
  67. echo &#092;"<center><a href=\"ksiega.php?id=$id\" class=\"linki\"> następne &gt;&gt; </a>\";
  68. }
  69. $id-=30;
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76.  
  77.  
  78. mysql_close($link);
  79. ?>

Błąd napewno znajduje się w wydzielonym fragmencie kodu .

Ten post edytował golden 15.01.2005, 13:46:03
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 1)
crash
post
Post #2





Grupa: Przyjaciele php.pl
Postów: 2 196
Pomógł: 2
Dołączył: 17.01.2004
Skąd: Sosnowiec

Ostrzeżenie: (0%)
-----


Skąd się wziął $id w ogóle? Pewnie zapomniałeś o użyciu _POST (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) Po co dajesz w cudzysłow id w zapytaniu SQL? Przecież to nie ciąg tylko liczba...
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.12.2025 - 19:29