|
Posted by "Daevid Vincent" on 08/13/05 00:43
First I'll appologize for the cheuvanistic remark the other poster had. I
know he had good intentions...
So I don't know smarty, but it seems to me you're grabbing only one row
here:
$projects = $db->getAssoc()
Normally in straight PHP, I would do something like.
While ($row = $db->getAssoc($query, DB_FETCHMODE_ASSOC))
{
$projects[] = $row;
}
The [] just adds a new element to the array and is dumping in the entire
$row array to it.
Ala, multi-dimensional array.
Then I would do something like:
foreach ($projects as $key => $value)
{
echo "[".$key."] has a name value of ".$value['project_name'];
}
Remember that you have a multi-array in $projects, so that's why I split it
into the key/value pair where value is actually another array, and you
access the elements via it's hash key.
Hope this helps.
D.Vin
http://daevid.com
> -----Original Message-----
> $query ="SELECT * FROM projects WHERE parent_project_id is NULL OR
> parent_project_id = ''";
>
> $projects = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
>
> foreach ($projects as $key => $project) {
> $query ="SELECT * FROM projects WHERE parent_project_id =
> $projects[$key]['project_id']";
> $sub = $db->getAssoc($query, DB_FETCHMODE_ASSOC);
> $projects[$key]['subs'] = $sub;
> }
> $tpl->assign('projects', $projects);
>
> SMARTY STUFF
> {foreach from=$projects item='entry'}
> <b>{$entry.short_name}</b><br />
> <ul>
> {foreach from=$entry.subs item='sub'}
> <li>{$sub.short_name}</li>
> {foreachelse}
> <li>No subs for this project</li>
> {/foreach}
> </ul>
> {foreachelse}
> <b>No projects found</b>
> {/foreach}
>
> Can anyone point me in the right direction?
>
> Thanks,
> Amanda
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
[Back to original message]
|