Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php]problem ze stronnicowaniem, droicyn
droicyn
post
Post #1





Grupa: Zarejestrowani
Postów: 6
Pomógł: 0
Dołączył: 12.04.2006

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


  1. <?php
  2.  
  3. // Dane z SQL'a do tablicy
  4. $count = 0;
  5. while($record_smiles = mysql_fetch_array($result_smiles))
  6. {
  7. $array_smiles[$count]['smile'] = $record_smiles['smile'];
  8. $array_smiles[$count]['file'] = $record_smiles['file'];
  9.  
  10. $count++;
  11. }
  12. if (isset($_GET['send']))
  13. {
  14. $int_poile = $_GET['submit_poile'];
  15. if(!isset($_GET['od']))
  16. {
  17. $int_od = 0;
  18.  
  19. }
  20. else
  21. {
  22. $int_od = $_GET['od'];
  23. }
  24. }
  25. else
  26. {
  27. $int_poile = 5;
  28. if(!isset($_GET['od']))
  29. {
  30. $int_od = 0;
  31.  
  32. }
  33. else
  34. {
  35. $int_od = $_GET['od'];
  36. }
  37. }
  38. $sql = "SELECT id, status, text_short, title, nick, image, link, date, mail FROM ne
    ws_news WHERE status='1' ORDER BY date DESC"
    ; 
  39. $result_num = mysql_query($sql);
  40. $newsy = 0;
  41. $newsy = mysql_num_rows($result_num);
  42.  
  43. $limit = ' LIMIT ' . $int_od . ', ' . $int_poile;
  44.  
  45. $sql = "SELECT id, status, text_short, title, nick, image, link, date, mail FROM ne
    ws_news WHERE status='1' ORDER BY date DESC $limit"
    ; 
  46. $result = mysql_query($sql);
  47.  
  48.  
  49. while($record = mysql_fetch_array($result))
  50. {
  51. if ($record['status'] == 1)
  52. {
  53. $id_news = $record['id'];
  54. $num_comments = 0;
  55.  
  56. $sql = "SELECT id, id_news FROM news_comments WHERE id_news='$id_news'";
  57. $result_comments = mysql_query($sql);
  58. $num_comments = mysql_num_rows($result_comments);
  59.  
  60. for ($i = 0; $i < count($array_smiles); $i++)
  61. {
  62. $record['text_short'] = str_replace($array_smiles[$i]['smile'], '<img src="images/smiles/icon_' . $array_smiles[$i]['file'] . '.gif" />', $record['text_short']);
  63. }
  64.  
  65. if(!empty($record['image']))
  66. {
  67. $image = '<img src="images/avatars/' . $record['image'] . '">';
  68. }
  69. else
  70. {
  71. $image = '';
  72. }
  73.  
  74. $link_short = $record['link'];
  75.  
  76. if(strlen($link_short) > 20)
  77. {
  78. $link_short = substr($link_short, 0,20);
  79. $link_short .= '...';
  80. }
  81.  
  82. if (!empty($record['link']))
  83. {
  84. $link = '<br /><br /><b>Link:</b> <a href="' . $record['link'] . '" target="_blank">' . $link_short . '</a>';
  85. }
  86. else
  87. {
  88. $link = '';
  89. }
  90.  
  91. //wyswietlam tutaj nick itp itd
  92.  
  93.  
  94. }
  95.  
  96. }
  97.  
  98. <table class="news_short" cellpadding="0" cellspacing="0" width="300">
  99. <form action="index.php" method="get">
  100. <tr>
  101. <td class="nick" width="70" align="center">Pokaż po</td>
  102. <td class="nick" width="60" align="center"><select name="submit_poile"><option>1<option selected>5<option>10<option>25</td>
  103. <td class="nick" width="110" align="center"> newsów na stronie</td>
  104. <td class="nick" width="60" align="center"><input type="submit" name="send" value="Pokaż" /></td>
  105. </tr>
  106. </form>
  107. </table>
  108. <br /><br />';
  109. $prev = $int_od - $int_poile;
  110. if($prev >=0)
  111. {
  112. echo '<a href="index.php?od=' . $prev . '"><span class="arrows">&laquo; Poprzednia&nbsp;&nbsp;</span></a>';
  113.  
  114. }
  115. else
  116. {
  117. echo '<span class="arrows2">&laquo; Poprzednia&nbsp;&nbsp;</span>';
  118.  
  119. }
  120. $_GET['x'] = 0;
  121. for($j = 0; $j<$newsy; $j+=$int_poile)
  122. {
  123. if ($j != 0)
  124. {
  125. echo '<span class="arrows">&nbsp;|&nbsp;</span>';
  126. }
  127. if($j == $_GET['od'])
  128. {
  129. echo '<b>'.($x + 1).'</b>';
  130. }
  131. else
  132. {
  133. echo '<a href="index.php?od=' . $j . '">' .($x + 1). '</a>';
  134. }
  135. $x++;
  136. }
  137. $next = $int_od + $int_poile;
  138. if($next<floor($newsy))
  139. {
  140. echo '<a href="index.php?od=' .$next . '"><span class="arrows">&nbsp;&nbsp;Następna&nbsp;&raquo;</span></a>';
  141.  
  142. }
  143. else
  144. {
  145. echo '<span class="arrows2">&nbsp;&nbsp;Następna&nbsp;&raquo;</span>';
  146.  
  147. }
  148.  
  149.  
  150. ?>
  151. i chodzi o to ze gdy wybiore zeby sortowal pojedynczo tzn zeby na kazdej stronie
     byl jeden news to podzieli dobrze ale gdy przejde na kolejna stronke to on zapomina o tym ze ma dzielic pojedynczo i d
    zieli ze jest ich po 5! 5 to jest domyslne jak to poprawic? 


---dodane---
I mam problem taki, że gdy wybiorę sortowanie po 1 newsie na stronie to gdy przejde np do 3 znow wyswietla mi po 5( bo tak jest ustawione domyslnie) jak mam zrobic zeby pamietal mi ze ma sortowac po 1 newsie albo gdyby tych newsow bylo 50 zeby to dzialalo przy sortowaniu po 10 na stronie(bo mam opcje ze sortuje 1 5 10 i 25)mam nadzieje ze teraz jest wszystko wporzadku i moj temat nie zostanie zablokowany
Go to the top of the page
+Quote Post

Posty w temacie


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: 22.08.2025 - 19:04