Re: [SMARTY] extracting data from mysql database

From: Date: Fri, 12 Apr 2002 08:12:59 +0000
Subject: Re: [SMARTY] extracting data from mysql database
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-3657@lists.php.net to get a copy of this message
Hello Blue, What you want is to assign an array and loop through it in the template. What you are doing is assigning the very last value of your data to Smarty Using classial {section} you might do : while($row = mysql_fetch_array($result)) { array_push ($myarray, array(
                'ids' =>$row["catId"],
                'cats' =>$row["category"] ))
} Smarty-> assign('idscats', $mayarray); i don't use html_options so you'll have to read the doc for the following.. Luc At 20:47 11/04/02 -0400, Blue Presley wrote:
I appreciate the help with my earlier question.. however after trying them all at least twice, none seemed to work. I'm sure it's something I'm doing (or not doing). Here is what I'm trying to do: Pull data from mysql using mysql_fetch_array() and then, using smarty, put that information into a <SELECT>menu. this is the code in my .php file: $sql = "select catId, category from categories"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { $smarty->assign("ids",$row["catId"]); $smarty->assign("cats",$row["category"]); } is this right? here is the Smarty code in my template: <select name="categories">
    {html_options values=$ids output=$cats}
    </select>
thanks again, blue


« previous php.smarty.general (#3657) next »