Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [Smarty] List/Menu ...
Luke
post
Post #1





Grupa: Przyjaciele php.pl
Postów: 215
Pomógł: 0
Dołączył: 28.10.2003
Skąd: -

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


Witam,

[php:1:985482a1f2]<?php
$rs = $db->GetAll("SELECT idArtykulu, tytul FROM pages");
?>[/php:1:985482a1f2]

wynikiem jest ...

Kod
Array ( [0] => Array ( [idArtykulu] => 1 [tytul] => Jakiś tam ) [1] => Array ( [idArtykulu] => 2 [tytul] => Jakiś tam ) )


Problem:

Z wynikow otrzymanych z bazy danych musze utworzyc List/Menu

[xml:1:985482a1f2]
<select name="_pageId" class="input">
<option label="{$idArtykulu}" value="{$idArtykulu}">{$tytul}</option>
</select>
[/xml:1:985482a1f2]

Nie znam Smarty na tyle dobrze aby poradzic sobie z tym problemem. Bardzo prosze o pomoc.

pozdrawiam
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
DeyV
post
Post #2





Grupa: Zarząd
Postów: 2 277
Pomógł: 6
Dołączył: 27.12.2002
Skąd: Wołów/Wrocław




Manual jak zwykle górą


index.php:
[php:1:0e707ec1fc]<?php
require('Smarty.class.php');
$smarty = new Smarty;
$smarty->assign('cust_options', array(
1001 => 'Joe Schmoe',
1002 => 'Jack Smith',
1003 => 'Jane Johnson',
1004 => 'Charlie Brown'));

$smarty->assign('customer_id', 1001);
$smarty->display('index.tpl');?>[/php:1:0e707ec1fc]


index.tpl:
[xml:1:0e707ec1fc]<select name=customer_id>
{html_options options=$cust_options selected=$customer_id}
</select>[/xml:1:0e707ec1fc]

OUTPUT:
[xml:1:0e707ec1fc]<select name=customer_id>
<option value="1000">Joe Schmoe</option>
<option value="1001" selected="selected">Jack Smith</option>
<option value="1002">Jane Johnson</option>
<option value="1003">Charlie Brown</option>
</select>[/xml:1:0e707ec1fc]
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: 9.10.2025 - 05:43