|
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 |
storm_2000 Smarty n00b
Joined: 03 Jan 2007 Posts: 2
|
Posted: Wed Jan 03, 2007 10:21 pm Post subject: MySQL et affichage des résultat |
|
|
Bonjour, j'aimerai afficher les résultat d'une requete.
mon code de template est le suivant :
Code: |
{include_php file="./header.php"}
{$NOM}
{section name=con loop=$contacts}
id : {$contacts[con].titre}
{/section}
|
et le code php est :
Code: |
<?php
include_once('./libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->assign("NOM","Bonjour ".$i );
mysql_connect("localhost","root","");
mysql_select_db("bernard");
$requete = mysql_query("SELECT titre FROM test");
$smarty->assign('contacts', mysql_fetch_array($requete) );
$smarty->display("index.tpl");
?>
|
merci de votre aide |
|
Back to top |
|
ciboulette Smarty Regular
Joined: 13 Jul 2006 Posts: 45
|
Posted: Thu Jan 04, 2007 1:07 am Post subject: |
|
|
bon deja ton $i tu va le chercher ou?
et le truc la ça serre a quoi? ta quoi dans ton fichier header?
Code: | {include_php file="./header.php"} |
et je te conseil le foreach a la place du section |
|
Back to top |
|
storm_2000 Smarty n00b
Joined: 03 Jan 2007 Posts: 2
|
Posted: Thu Jan 04, 2007 11:42 am Post subject: |
|
|
$i c'est une erreur de copie.
dans le fichier header, j'ai :
Code: |
<?php
include_once('./libs/Smarty.class.php');
$smarty = new Smarty();
$smarty->caching = 2;
$smarty->cache_lifetime = 300;
$smarty->assign("titre","Bonjour");
$smarty->display("header.tpl");
?>
|
Code: |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>{$titre}</title>
</head>
|
|
|
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
|