Re: [SMARTY] assign() Problem - Urgent

From: Date: Mon, 14 Jul 2003 15:33:15 +0000
Subject: Re: [SMARTY] assign() Problem - Urgent
References: 1  Groups: php.smarty.general 
Request: Send a blank email to php-smarty-general+get-9888@lists.php.net to get a copy of this message
Balaji You might want to re-write your code. My guess is that you are a C programmer! See the following example....change the fields to suit your needs. Smarty rules...and have urgent day! index.php ------------------ /*select whatever fields you want from the table Projects */ $query = "SELECT * FROM Projects where status='active'"; $result = db_query($query); /* fetch mysql results and store them in an associative array */ while ($projects[]= mysql_fetch_array($result, MYSQL_ASSOC)); $template = new template; $template->assign('projects',$projects); $template->display('index.tpl'); ----------------- index.tpl --------------------------- <table cellpadding="4" cellspacing="1" border="0" align="center" width="100%"> <tr> <td bgcolor="#004D88" colspan="6"> <b>ACTIVE PROJECTS</b><br> </td></tr> {section name="i" loop=$projects} {cycle values="#EAEAEA,#FFFFFF" assign="row_color"} <tr bgcolor="{$row_color}"> <td>{$tickets[i].project_id}</td> <td>{$tickets[i].project_desc}</td> <td>{$tickets[i].project_status}</td> <td>{$tickets[i].project_whatever}</td> </tr> {if $smarty.section.i.last} <tr> <td colspan="4"> Total of {$smarty.section.i.total} Projects are in Active status. </td> </tr> {/if} {sectionelse} <tr> <td colspan="4"> No Projects are in active status </td> </tr> {/section} </table> -- Peter Rotich -- "A likely impossibility is always preferable to an unconvincing possibility." Aristotle, Green philosopher (384-322BC)

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