Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Pomoc dla nowicjusza :-)

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish
View previous topic :: View next topic  
Author Message
Aziq52
Smarty n00b


Joined: 07 Aug 2009
Posts: 2

PostPosted: Fri Aug 07, 2009 2:42 pm    Post subject: Pomoc dla nowicjusza :-) Reply with quote

Witam. Nie dawno zacząłem swoją przygodę ze Smarty. Mam mały problem z pętlą i wyświetlaniem iformacji z bazy MySql

Proszę o zrobienie pętli wyświetlajacej dane z bazy news:
title, news, autor, date

I oczywiśćie kod do *.tpl

Z góry dziękuje i pozdrawiam Wink
Back to top
View user's profile Send private message
Aziq52
Smarty n00b


Joined: 07 Aug 2009
Posts: 2

PostPosted: Mon Aug 10, 2009 8:30 am    Post subject: Reply with quote

Who can help me?
Jest tu ktoś wogóle na tym forum ? Laughing
Back to top
View user's profile Send private message
human
Smarty Rookie


Joined: 21 Oct 2005
Posts: 12
Location: Helldorado

PostPosted: Tue Aug 18, 2009 1:53 pm    Post subject: Reply with quote

http://smarty.net/manual/en/language.function.foreach.php
Przyklad 7-7
Taka tablice chyba nie problem zbudowac? Smile
Back to top
View user's profile Send private message Visit poster's website
ma_po
Smarty Rookie


Joined: 09 Jul 2008
Posts: 5

PostPosted: Thu Aug 20, 2009 8:29 am    Post subject: Re: Pomoc dla nowicjusza :-) Reply with quote

Aziq52 wrote:
Witam. Nie dawno zacząłem swoją przygodę ze Smarty. Mam mały problem z pętlą i wyświetlaniem iformacji z bazy MySql

Proszę o zrobienie pętli wyświetlajacej dane z bazy news:
title, news, autor, date

I oczywiśćie kod do *.tpl

Z góry dziękuje i pozdrawiam Wink


YO!
Panie od groma jest tego w sieci.
Polecam http://www.rzseattle.org/docs/smartypl/

Warto wyrobić sobie trochę samodzielności bo ludzie ..#@$ Very Happy


Poniżej prosty przykład jak by coś nie szło to pisz.
Pozdro.


PHP poniżej:

Code:

<?php
include ("../smarty/libs/Smarty.class.php");
$smarty = new Smarty();

//tablica
$tab = array();

//polaczenie z baza
$laczenie = mysql_connect(HOST.":".PORT, USER, HASLO);
      
if(mysql_select_db(DBNAME, $laczenie))
{
    $zapytanie = mysql_query("SELECT * FROM news");
 
    while ($row = mysql_fetch_assoc($zapytanie))
    {
        $tab = $row;
    }
}
mysql_close($laczenie);

$smarty->assign( 'contentnews', $tab);
$smarty->display("index.tpl");

?>




SMARTY index.tpl ponizej:

Code:

<html>
<body>
       {foreach item="n" from="$contentnews"}
          to jest data: {$n.date}<br/>
          to jest autor: {$n.autor}<br/>
          to jest news: {$n.news}<br/>
          to jest tytuł: {$n.title}<br/>
       {/foreach}
</body>
</html>
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Language: Polish All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP