You are here: Re: [SMARTY] looping through variable names « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] looping through variable names

Posted by "Cal Henderson" on 08/18/05 03:13

Kathleen Krause-Thompson <kkthompson@tsl.state.tx.us> wrote:
: That doesn't quite answer my question. Here is another posting with
: the php.
:
: <?php
: for ($i=1;$i<=$_SESSION['budgetPos'];$i++) {
: $str = 'budget' . $i;
: if (isset($_SESSION[$str])) {
: $smarty->assign($str,$_SESSION[$str]);
: }
: }

change the php:

<?php
$bits = array();

for ($i=1;$i<=$_SESSION['budgetPos'];$i++) {
$str = 'budget' . $i;
if (isset($_SESSION[$str])) {
$bits[$str] = $_SESSION[$str];
}
}

$smarty->assign_by_ref('budgets', &$bits);
?>


then smarty:


{foreach from=$budgets item='budget'}
<p>Job Title: {$budget.jobTitle} Percent of Full
Time:{$budget.percentFullTime}</p>
{/foreach}


--cal

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация