解决方案 »

  1.   

    if(cid == id)
    这条cid数据就放在id数据后面    说不清楚了~~~~
      

  2.   

    select id, ctype, cid, name, ifshow, vieworder, opennew, url, type from vm_nav where ifshow and cid=0
    union
    select cid as id, ctype, cid, name, ifshow, vieworder, opennew, url, type from vm_nav where ifshow and cid>0
    order by id
      

  3.   

    这样取出来的数据 cid在父id前面:如
    INSERT INTO `vm_nav` (`id`, `ctype`, `cid`, `name`, `ifshow`, `vieworder`, `opennew`, `url`, `type`) VALUES
    (2, NULL, 0, 'product', 1, 2, 0, '', 'nav'),
    (3, NULL, 3, 'member_info', 1, 2, 0, '', 'nav'),
    (3, NULL, 3, 'member_index', 1, 1, 0, '', 'nav'),
    (3, NULL, 0, 'member', 1, 3, 0, '', 'nav'),
    (4, NULL, 0, 'guide', 1, 4, 0, '', 'nav'),
    (5, NULL, 0, 'kehu', 1, 5, 0, '', 'nav'),
    (6, NULL, 0, 'about', 1, 6, 0, '', 'nav'),
    (7, NULL, 0, 'tehui', 1, 7, 0, '', 'nav');
    好像是我吧事情搞复杂了~   ~ 
      

  4.   

    嗯 ,但 一维数组中如果有cid则需要排在cid后面,cid可以理解为父节点的下标,根节点的cid=0~~~   大概就这个意思 ~
      

  5.   

    不应该的,排序键相同时是按自然顺序的可带上 cid 排序
    order by id, cid