You are here: Re: [SMARTY] Re: Nested queries/nested arrays « Smarty Templates Posts « IT news, forums, messages
Re: [SMARTY] Re: Nested queries/nested arrays

Posted by Gary Smith on 08/13/05 02:18

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 42FCF52F.9040707@indiana.edu, Amanda Hemmerich at
ahemmeri@indiana.edu 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);

 

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

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