Re: [SMARTY] Re: Nested queries/nested arrays

Gary Smith <[email protected]>
Newsgroups gmane.comp.php.smarty.general
Message-ID <BF225215.55929%[email protected]>
Hi Amanda,

Try this:


$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) {
 if (!empty($project['project_id'])){

    $id = $project['project_id'];
    $query ="SELECT * FROM projects WHERE project_id = ? ";

    $sub = $db->getAssoc($query, false, array($id));
    $projects[$key]['subs'] = $sub;
 }
}

$tpl->assign('projects', $projects);

Gary


in article [email protected], Amanda Hemmerich at
[email protected] wrote on 8/12/05 9:14 AM:

> $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) {
>  if (!empty($project[$key]['project_id'])){
> 
>     $id = $project[$key]['project_id'];
>     $query ="SELECT * FROM projects WHERE parent_project_id = ? ";
> 
>     //$sub = $db-> getAssoc($query, false, array($id));
>     //$projects[$key]['subs'] = $sub;
>  }
> }
> 
> $tpl->assign('projects', $projects);

-- 
Smarty General Mailing List (http://smarty.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.