Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP] tasowanie, sortowanie banerow
blown
post
Post #1





Grupa: Zarejestrowani
Postów: 34
Pomógł: 0
Dołączył: 16.03.2009

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


Witam,
mam pewien problem z przetasowaniem. Ponieważ napisałem sobie skrypt który wyświetla mi np 20 bannerow które chce przetasować po każdym odświeżeniu strony żeby zamieniły się pozycjami. Próbuje opcją shuffle ale jakoś niechce mi to wyjść ;/ bardzo był bym wdzieczny gdyby ktos mi wytlumaczył jak to zrobic.

Kod
$bannery = array(print '<a href="'.stripslashes($row["Link strony"]) .'"target="_blank">'. '<img src="'.stripslashes($row["baner_url"]) .'"border="0"/>'.'</a>');

shuffle($bannery);
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
_olo_1984
post
Post #2





Grupa: Zarejestrowani
Postów: 289
Pomógł: 77
Dołączył: 5.08.2006

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


jeżeli uda ci się zapytaniem wyciągnąć wszystkie banery i linki do nich z bazy i wsadzić to do takiej tablicy:
  1. <?php
  2. $banery = array(
  3. 0 => array('link_strony' => 'link_1', 'baner_url' => 'url_1'),
  4. 1 => array('link_strony' => 'link_2', 'baner_url' => 'url_2'),
  5. 2 => array('link_strony' => 'link_3', 'baner_url' => 'url_3'),
  6. 3 => array('link_strony' => 'link_4', 'baner_url' => 'url_4'),
  7. 4 => array('link_strony' => 'link_5', 'baner_url' => 'url_5')
  8. );
  9. ?>


to by je posortować i wyświetlić wystarczą opdane przez kolege wyżej funkcje:
  1. <?php
  2. shuffle($banery);
  3.  
  4. foreach($banery as $baner)
  5. {
  6.    echo '<a href="'.stripslashes($baner['link_strony']).'" target="_blank"> <img src="'.stripslashes($baner['baner_url']).' "border="0"/> </a>';
  7. }
  8. ?>


a ty masz jeden wpis w tablicy który chcesz tasować. Pokaż zapytanie, oraz to co ono zwraca
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: 2.10.2025 - 17:24