array messing up

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

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i don't know if this is the right list to post it, or php-general...
I am posting here because i think its database related.

so here we go:

I want to build an array containing two arrays $navm[] and $navs[],
$navs[] should go to $navm[items].

I am using an commercial db class to do my queries.

This is the snippet making my array:

- -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");
     
               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<------------------------------

table looks like this:
- -table:start-------------------------8<------------------------------
 CREATE TABLE `ui_cats` (
   `catid` tinyint(11) NOT NULL auto_increment,
   `ms` char(1) NOT NULL default 's',
   `master` tinyint(1) NOT NULL default '1',
   `sortorder` tinyint(3) NOT NULL default '0',
   `name` varchar(150) NOT NULL default '',
   `link` varchar(150) NOT NULL default '',
   PRIMARY KEY  (`catid`)
   ) TYPE=MyISAM AUTO_INCREMENT=8 ;
- -table:stop--------------------------8<------------------------------
 
MySQL Version: 3.23.58
PHP-Version:   4.2.2
( I can not update those versions..)

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? i cant see it after trying several other querys in
two days :-(

any ideas?
thanks in advice
- -- 
- ---------------------------------------------------------------------
Rainer 'Ny' Bendig | http://UnresolvedIssue.org | GPG-Key: 0xCC7EA575
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (GNU/Linux)

iD8DBQFBni4ltpAZoWtAN98RAi18AJ9ToJhWXlvJiVVE/GoH3ArHTYN/cACdHzU4
dU9lkx+M8UnVQPak/+ikQYs=
=su6z
-----END PGP SIGNATURE-----

-- 
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