Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Problem z smarty, (linki do stron np. Przejdź do strony: 1,2,3...)
gandziorz
post
Post #1





Grupa: Zarejestrowani
Postów: 101
Pomógł: 0
Dołączył: 20.12.2006

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


Witam,
Mam do wszystkich prośbę jak coś takiego wykonać w smarty?

SQL/php
  1. <?php
  2. //(...)
  3. $strona = (int)$_GET['strona'];
  4. if (empty($strona) or $strona==1) {
  5. $strona = 1;
  6. $str1 = 1;
  7. $str2 = 20;
  8. } else {
  9. $str1 = $strona*20-19;
  10. $str2 = $strona*20;
  11. }
  12.  
  13. //pobieranie danych wg. kryteriow
  14. $sql = "SELECT * FROM ogloszenia WHERE kategoria='$kat' AND status=3 ORDER BY id DESC LIMIT $str1, $str2";
  15. if($res = mysql_query ($sql)) {
  16. $znalazl = mysql_num_rows($res);
  17. $stron = @floor($znalazl/20);
  18. if ($stron < 1) {
  19. $stron = 1;
  20. } elseif ($strona > $stron) {
  21. $strona = $stron;
  22. }
  23. for ($i=1; $i<$stron; $i++) {
  24. $strony = $i;
  25. }
  26. for ($i=1; $i<$znalazl; $i++) {
  27. $wiersz = mysql_fetch_array($res);
  28. $ogloszenia[$i] = $wiersz;
  29. }}
  30.  
  31. $smarty->assign ('ogloszenia', $ogloszenia);
  32. $smarty->assign ('strona', $strona);
  33. $smarty->assign ('stron', $stron);
  34. $smarty->assign ('strony', $strony);
  35. $smarty->assign ('katstr', $kat);
  36. $smarty->assign ('str1', $str1);
  37. $smarty->assign ('str2', $str2);
  38. $smarty->display ('ogloszenia.tpl');
  39. ?>


Smarty:
  1. {section name=a loop=$strony}
  2. <a href="kategoria,{$katstr},{$strony[a]}.html">{$strony[a]}</a>
  3. {if $strona == $strony[a]}
  4. <b><a href="kategoria,{$katstr},{$strony[a]}.html">{$strony[a]}</a></b>
  5. {/if}
  6. {/section}


Ten post edytował gandziorz 22.01.2007, 01:14:40
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 - 16:45