![]() |
![]() |
![]()
Post
#1
|
|
Grupa: Zarejestrowani Postów: 116 Pomógł: 4 Dołączył: 9.10.2007 Skąd: Morąg Ostrzeżenie: (0%) ![]() ![]() |
To jest moj plik.tpl
Kod {$today} {include file="header_ivt.tpl"} <table align="center" width="70%"> <tr> <td colspan="16" class="tab_uberschrift_1" align="center">Info About current rents</td> </tr> <tr> <th colspan="2" class="tab_uberschrift_1">Num</th> <th colspan="2" class="tab_uberschrift_1">Category</th> <th colspan="2" class="tab_uberschrift_1">Name</th> <th colspan="2" class="tab_uberschrift_1">RentDate</th> <th colspan="2" class="tab_uberschrift_1">Owner</th> <th colspan="2" class="tab_uberschrift_1">RentPerson</th> <th colspan="2" class="tab_uberschrift_1">RentForPerson</th> <th colspan="2" class="tab_uberschrift_1">GetBackDate</th> </tr> {foreach name=rent item=rent from=$rent} {if $today gt $rent.getbackdate} <tr> <td class="tab_uberschrift_2" colspan="2" align="center">{$smarty.foreach.rent.iteration}</td> {foreach name=ren1 from=$rent item=rent} <td class="tab_uberschrift_2" colspan="2" align="center">{$rent}</td> {/foreach} <td class="tab_uberschrift_2" align="center"><a href="cal.html"><img src="gfx/datechooser.png" alt="EDIT DATE" ></a></td> </tr> {else} <tr> <td class="tab_uberschrift_3" colspan="2" align="center">{$smarty.foreach.rent.iteration}</td> {foreach name=ren2 from=$rent item=rent} <td class="tab_uberschrift_3" colspan="2" align="center">{$rent}</td> {/foreach} <td class="tab_uberschrift_3" align="center"><a href="cal.html"><img src="gfx/datechooser.png" alt="EDIT DATE" ></a></td> </tr> {/if} {/foreach} </table> Problem polega na tym ze jak chce wyswietic tabele w zaleznosci od warunku if (wiersz tabeli ma miec kolor1 lub kolor2 z css'a). Zmienna $rent jest tablica. Mam wrazenie jakby brany byl tylko pierwszy element tablicy choc jest w petli. Gdy zmienie warunek z gt- (>) na lt- (<) to wtedy wszystkie wiersze zaznaczone sa na kolor 2. Podejrzewam ze mam blad w petli, albo w warunku. Prosze o pomoc |
|
|
![]() |
![]()
Post
#2
|
|
Grupa: Zarejestrowani Postów: 405 Pomógł: 1 Dołączył: 19.09.2003 Skąd: Lublin Ostrzeżenie: (0%) ![]() ![]() |
Bierzesz element z tablicy $rent i wpisujesz go do zmiennej o nazwie $rent... ciekawe czemu drugi obrót pętli się nie wykonuje? Zrób tak: A wewnątrz pętli odwołuj się przez $rent_item. |
|
|
![]()
Post
#3
|
|
Grupa: Zarejestrowani Postów: 116 Pomógł: 4 Dołączył: 9.10.2007 Skąd: Morąg Ostrzeżenie: (0%) ![]() ![]() |
Z tego co zrozumialem to zrobilem tak:
Kod {foreach name=rent item=rent_item from=$rent} {if $smarty.now|date_format:"%Y-%m-%d" gt $rent.getbackdate} <tr> <td class="tab_uberschrift_2" colspan="2" align="center">{$smarty.foreach.rent.iteration}</td> {foreach name=ren1 from=$rent_item item=rent} <td class="tab_uberschrift_2" colspan="2" align="center">{$rent}</td> {/foreach}<form name="date" action="data.php" method="POST"> <td class="tab_uberschrift_2" align="center"><a onclick="showKal(this)"><img src="gfx/datechooser.png" alt="EDIT DATE"></a></td></form> </tr> {else} <tr> <td class="tab_uberschrift_3" colspan="2" align="center">{$smarty.foreach.rent.iteration}</td> {foreach name=ren1 from=$rent_item item=rent} <td class="tab_uberschrift_3" colspan="2" align="center">{$rent}</td> {/foreach}<form name="date" action="date.php" method="POST"> <td class="tab_uberschrift_3" align="center"><a onclick="showKal(this)"><img src="gfx/datechooser.png" alt="EDIT DATE"></a></td></form> </tr> {/if} {/foreach} Ale pomimo to wyswietla mi sie dalej to samo, tzn. nie podswietla elementow spelniajacych warunek |
|
|
![]()
Post
#4
|
|
Grupa: Zarejestrowani Postów: 1 116 Pomógł: 119 Dołączył: 10.05.2005 Skąd: Poznań Ostrzeżenie: (0%) ![]() ![]() |
|
|
|
![]()
Post
#5
|
|
Grupa: Zarejestrowani Postów: 116 Pomógł: 4 Dołączył: 9.10.2007 Skąd: Morąg Ostrzeżenie: (0%) ![]() ![]() |
Kod jojo napisał: HTML {foreach name=rent item=rent_item from=$rent} a Ty napisałeś: HTML {foreach name=ren1 from=$rent_item item=rent} widzisz różnicę? Pierwszy foreach to petla zewnetrzna, a drugi to wewnetrzna do ktorej sie chce odwolac. Jesli wpisalbym w petle to co mi podales to petle nie zadzialaja. Nie wiem przypadkiem czy blad dzialania petli nie jest spowodowany warunkiem. Sprawdzalem rozne kombinacje (gt,ge,lt,le,eq) i za kazdym razem dane wyswietla nieprawidlowo, tzn. nie podkresla mi odpowiednich rekordow. pozdr Na pewno blad spowodowany warunkiem!!! I teraz pytanie : Kod {if $smarty.now|date_format:"%Y-%m-%d" gt $rent.getbackdate} , tu mam instrukcje warunkowa if. dalej jest porownanie i blad wystepuje w wyswietleniu przez $rent_item.r_getbackdate, otoz powinna to byc data a jak chce wyswietlic sama date to wywala mi tylko pierwsza cyfre. Np. jak mam rok 2007 to do porównania jest brana tylko 2!! Jak zrobic zeby bral cala date?
Ten post edytował gutek84 25.10.2007, 06:48:42 |
|
|
![]()
Post
#6
|
|
Grupa: Postów: 4 Pomógł: 0 Dołączył: 7.11.2004 Ostrzeżenie: (10%) ![]() ![]() |
Dokładnie tak
{foreach name=ren1 from=$rent_item item=rent} |
|
|
![]() ![]() |
![]() |
Aktualny czas: 24.08.2025 - 11:11 |