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

MySQL et affichage des résultat

 
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: French
View previous topic :: View next topic  
Author Message
storm_2000
Smarty n00b


Joined: 03 Jan 2007
Posts: 2

PostPosted: Wed Jan 03, 2007 10:21 pm    Post subject: MySQL et affichage des résultat Reply with quote

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
View user's profile Send private message
ciboulette
Smarty Regular


Joined: 13 Jul 2006
Posts: 45

PostPosted: Thu Jan 04, 2007 1:07 am    Post subject: Reply with quote

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
View user's profile Send private message
storm_2000
Smarty n00b


Joined: 03 Jan 2007
Posts: 2

PostPosted: Thu Jan 04, 2007 11:42 am    Post subject: Reply with quote

$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
View user's profile Send private message
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: French 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