Forum Moderators: coopster
function getPicks($thisyear, $thisweek){
$sql = "SELECT * FROM teampicks
WHERE year = '" . $thisyear . "' AND week = '" . $thisweek . "' ORDER BY username"; $res = mysql_query($sql);
$c=0;
while ($a_row = mysql_fetch_array($res)) {
for($i = 1; $i < 100; $i++) {
if ($a_row["game$i"] == "0") {// 0 is a pass
}else {
$pData[$c]["username"] = $a_row["username"];
$pData[$c]["year"] = $a_row["year"];
$pData[$c]["week"] = $a_row["week"];
//Set dynamic game colums
$pData[$c]["game$i"] = $a_row["game$i"];
$pData[$c]["game_id$i"] = $a_row["game_id$i"];
}
}
$c++;
}
return $pData;
}
which is called via this in the php file and then sets a variable in a smarty templete
$pData = getPicks($thisyear, $thisweek);
$smarty->assign('pData',$pData);
then it gets displayed in the smarty template
{section name=picks loop=$pData}
<p>{$pData[picks].username} Picks for the {$pData[picks].year} Seasone Week {$pData[picks].week}</p>
<p>
<ul>
<li> Team Id {$pData[picks].game1} GameID: {$pData[picks].game_id1}</li>
<li> Team Id {$pData[picks].game2} GameID: {$pData[picks].game_id2}</li>
</ul>
</p>
{/section}
so if I manually add 3 then 4 to the end of {$pData[picks].game} all is well and this is ok if there is no other way but I would like to add an auto increment for the number in the smarty template.
I have tried using the {counter name=1} built in function with smarty but it does not seem to work inside the variable like so
{$pData[picks].game{counter name=1}}
Any help is appreciated.
Regards,
Brandon
{section name=picks loop=$pData}
<p>{$pData[picks].capper}'s Picks for the {$pData[picks].year} Season Week {$pData[picks].week}</p>
<p>
<ul>
{if $pData[picks].game1}
<li> Team Id {$pData[picks].game1} {$pData[picks].r1}{$pData[picks].t1}{$pData[picks].s1}</li>
{/if}
{if $pData[picks].game2}
<li> Team Id {$pData[picks].game2} {$pData[picks].r2}{$pData[picks].t2}{$pData[picks].s2}</li>
{/if}
{if $pData[picks].game3}
<li> Team Id {$pData[picks].game3} {$pData[picks].r3}{$pData[picks].t3}{$pData[picks].s3}</li>
{/if}
{if $pData[picks].game4}
<li> Team Id {$pData[picks].game4} {$pData[picks].r4}{$pData[picks].t4}{$pData[picks].s4}</li>
{/if}
{/section}
I even posted to the smarty forums and no luck there. I tried a couple modifier plugins I found there and no luck either.
Regards,
Brandon,
bRANDON