Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

while untar while

[es] :: PHP :: Smarty template engine :: while untar while

[ Pregleda: 2932 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

glavince
Ohrid/Macedonia

Član broj: 66412
Poruke: 246
62.162.91.*

Sajt: ohridnews.com


Profil

icon while untar while12.12.2006. u 21:01 - pre 211 meseci
Posle duzeg vremena odlucio sam da se malo zanimavam sa smartijem.
U sustini nije strasan ko sto na prvi pogled izgleda.
Ali mi je potrebna mala pomoc:
Ovo je php fajl
Code:

$sql = "select * from kategorii_vesti where kat_id = '0'";
$results = mysql_query($sql);
$data = array();
while($row = mysql_fetch_array($results)) {
$data[] = $row;
}

Ovo je tpl:
Code:

{section name=menu loop=$rezultat}
   <a href="index.php?id={$rezultat[menu].id}">{$rezultat[menu].naziv}</a><br />
{sectionelse}
   <p>Nema rezultat<p />
{/section}
       // ili //
{foreach from=$rezultat item="menu"}
  <a href="index.php?id={$menu.id}">{$menu.naziv}</a><br />
{/foreach} 

E sad ne znam za sta tacno sluzi "section " a za sta "foreach". sem sto ima "{sectionelse}"

I drugo pitanje koje mi je vaznije.
Kako bi ovo vi preveli u smaty
Code:

$sql = "select * from kategorii_vesti where kat_id = '0'";
$results = mysql_query($sql);
while($row = mysql_fetch_array($results)) {
echo $row['naziv'];
    $sql1 = "select * from kategorii_vesti where kat_id = '".$row['id']."'";
    $results1 = mysql_query($sql1);
    while($row1 = mysql_fetch_array($results1)) {
        echo $row1['naziv'];
    }
}




 
Odgovor na temu

VladaSu

Član broj: 31634
Poruke: 1099
77.46.157.*



+218 Profil

icon Re: while untar while28.06.2007. u 17:30 - pre 204 meseci
Section i foreach imaju istu svrhu samo drugacie osobine.

[Ovu poruku je menjao VladaSu dana 14.06.2003. u 11:22 GMT+1]
 
Odgovor na temu

[es] :: PHP :: Smarty template engine :: while untar while

[ Pregleda: 2932 | Odgovora: 1 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.