RE: Starting probs

From: Date: Tue, 07 Aug 2001 16:33:45 +0000
Subject: RE: Starting probs
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-1316@lists.php.net to get a copy of this message
> Here's what I've tried: > ######## test.php ######## > require_once("Smarty.class.php"); > $smarty = new Smarty; > $smarty->compile_check = true; > $smarty->debugging = true; > $sql = "SELCT uid, uname, email FROM users ORDER BY uname LIMIT 0,25"; I quess the "SELCT" is a typo in this example and not in your script? :) > $result = mysql_query($sql) or die("bla"); > $smarty->assign("data", mysql_fetch_array($result)); This will assign only the first row of returned data from your query to the smarty variable {$data}. To assign all 25, you will have to run through a for loop before you make the assignment to the smarty template. > $smarty->display("test.tpl"); > > ###### test.tpl ########## > <table border='1'> > <tr> > <td>UID > <td>UNAME > <td>EMAIL > {section name=user loop=$data} > <tr {if %user.rownum% is even}style='background-color: silver;'{/if}> > <td>{$user[uid]} > <td>{$user[uname]} > <td>{$user[email]} the format to access associated arrays is $user.uid $user.uname $user.email using the [] syntax will cause your output ;) be cool, G

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