For Programmers: Free Programming Magazines  


Home > Archive > PHP Smarty Templates > January 2005 > Re: [SMARTY] passing result arrays to Smarty template









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [SMARTY] passing result arrays to Smarty template
Bertrand Zuchuat

2005-01-12, 4:03 pm


Le 12 janv. 05, =E0 17:39, Kathleen Krause-Thompson a =E9crit :

> $sql =3D "SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM =

ORGANIZATION";
> $result =3D mysql_query($sql);
> while ($row =3D mysql_fetch_array($result)) {
> $smarty->assign("organizations", array("ID" =3D> $row[0],
>
> "ORGANIZATION_NAME" =3D> $row[1] ));
> }


Hello,

$sql =3D "SELECT ORGANIZATION_ID, ORGANIZATION_NAME FROM ORGANIZATION";
$result =3D mysql_query($sql);
$a_organizations =3D array();
while ($row =3D mysql_fetch_array($result)) {
$a_organizations[$row[0]] =3D $row[1];
}
$smarty->assign('organizations', $a_organizations);

{foreach from=3D$organizations key=3DID item=3DORGANIZATION_NAME}
{$ID} {$ORGANIZATION_NAME} <br>
{/foreach}

Bye

Bertrand=
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com