Re: array messing up

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rainer Bendig Aka Ny wrote:
I want to build an array containing two arrays $navm[] and $navs[],
$navs[] should go to $navm[items].

- -sourcecode:start--------------------8<------------------------------

$resultm = $db->query("SELECT * FROM ".$p."_cats  WHERE ms='m' \
           ORDER BY sortorder ASC");
while($work_res_navm = $db->fetch_array($resultm)) {
      $results = $db->query("SELECT * FROM ".$p."_cats  \
                 WHERE master='".$work_res_navm['catid']."' \
		 ORDER BY sortorder ASC");

$navs = array();

while($work_res_navs = $db->fetch_array($results)) {
$navs[]=array('link'=>$work_res_navs['link'], \
'text'=> $work_res_navs['name'], \
'id'=> $work_res_navs['catid'], \
'master'=>$work_res_navs['master']
);
}
$navm[] =array('link'=>$work_res_navm['link'], \
'text'=> $work_res_navm['name'], \
'id'=> $work_res_navm['catid'], \
'items'=>$navs);
};
- -sourcecode:stop---------------------8<------------------------------


the array now looks like this:
$navm1-0
     $navs1-1
     $navs1-2
$navm2-0
     $navs1-1
     $navs1-2
     $navs2-1
$navm3-0
     $navs1-1
     $navs1-2
     $navs2-1
     $navs3-1

and the same procedure a lot more often... but it should look like
this:
$navm1-0
     $navs1-1
     $navs1-2
$navm2-0
     $navs2-1
$navm3-0
     $navs3-1
and so on

what is my error?

you forget to empty the array $navs!

--
Sebastian Mendel

www.sebastianmendel.de www.warzonez.de www.tekkno4u.de www.nofetish.com
www.sf.net/projects/phpdatetime        www.sf.net/projects/phptimesheet

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux