|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
Aziq52 Smarty n00b
Joined: 07 Aug 2009 Posts: 2
|
Posted: Fri Aug 07, 2009 2:42 pm Post subject: Pomoc dla nowicjusza :-) |
|
|
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 |
|
Back to top |
|
Aziq52 Smarty n00b
Joined: 07 Aug 2009 Posts: 2
|
Posted: Mon Aug 10, 2009 8:30 am Post subject: |
|
|
Who can help me?
Jest tu ktoś wogóle na tym forum ? |
|
Back to top |
|
human Smarty Rookie
Joined: 21 Oct 2005 Posts: 12 Location: Helldorado
|
|
Back to top |
|
ma_po Smarty Rookie
Joined: 09 Jul 2008 Posts: 5
|
Posted: Thu Aug 20, 2009 8:29 am Post subject: Re: Pomoc dla nowicjusza :-) |
|
|
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 |
YO!
Panie od groma jest tego w sieci.
Polecam http://www.rzseattle.org/docs/smartypl/
Warto wyrobić sobie trochę samodzielności bo ludzie ..#@$
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 |
|
|
|
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
|