passing result arrays to Smarty template

From: Date: Wed, 12 Jan 2005 16:39:25 +0000
Subject: passing result arrays to Smarty template
Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-12151@lists.php.net to get a copy of this message
Hello--I am trying to pass mysql result arrays to a Smarty template as one associative array. I have the code below, but it results in only 1 result row being passed to the template. How could every row be passed? I am grateful for any assistance. <?php $sql = "SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION"; $result = mysql_query($sql); while ($row = mysql_fetch_array($result)) { $smarty->assign("organizations", array("ID" => $row[0], "ORGANIZATION_NAME" => $row[1] )); } ?> {foreach from=$organizations key=ID item=ORGANIZATION_NAME} {$ID} {$ORGANIZATION_NAME} <br> {/foreach}

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