Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php][mysql] wyświetlanie losowe, [php][mysql]
kupiepsa.com
post
Post #1





Grupa: Zarejestrowani
Postów: 27
Pomógł: 0
Dołączył: 23.01.2008

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


Witam serdecznie,
mam taki o to kod php:
  1. <?php
  2.  require_once 'libs/DBmanager.php';
  3.  require_once 'libs/display.php';
  4.  
  5.  
  6.  function smarty_function_pokaz_promowane($param, $smarty) 
  7.  {
  8.  DBmanager::connect();
  9.  $result = mysql_query("select * from katalog where promowanie='1' and status='1' order by id DESC LIMIT ".IL_PROMOWANYCH);
  10.  while($row = mysql_fetch_array($result))
  11.  {  
  12. $smarty -> assign("grupa_hodowli", display::convCategory($row['grupa_hodowli']));
  13. $smarty -> assign("miasto", $row['miasto']);
  14. $smarty -> assign("nazwa_hodowli", $row['nazwa_hodowli']);
  15. $smarty -> assign("zdjecie", display::getPhotoThumb($row['login']));
  16. $smarty -> assign("link", "location.href='oferty/".$row['id'].".html'");
  17. $smarty -> display("oferta_promowana.tpl");
  18.  }
  19.  }
  20.  
  21. ?>


powyzsza funkcja wyswietla tyle promowanych hodowli ile jest zapisanych w pliku config:
  1. <?php
  2. define('IL_PROMOWANYCH', 3);
  3. ?>


probowalem zastapic linie :
$result = mysql_query("select * from katalog where promowanie='1' and status='1' order by id DESC LIMIT ".IL_PROMOWANYCH);

1 próba :
  1. <?php
  2. $result = mysql_query("select * from katalog where promowanie='1' and status='1' order by random id DESC LIMIT ".IL_PROMOWANYCH);
  3. ?>


2 próba :
  1. <?php
  2. $result = mysql_query("select * from katalog where promowanie='1' and status='1' order by id DESC LIMIT ".IL_PROMOWANYCH)AS alias ORDER BY RAND() LIMIT 3 ;
  3. ?>


powyzsze nie dzialaja ....
chodzi o to, ze w tej chwili sa ustalone 3 oferty promowane, a promowanych jest obecnie 11 i chcialbym by losowo byly wyswietlane 3.
Moge prosic o pomoc ?
Pozdrawiam
Arek


--------------------
http://www.kupiepsa.com
Bezpłatne Ogłoszenia
http://www.vet.info.pl
Baza Hodowców
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 19.08.2025 - 16:21