Problem in xml tree menu . PHP/SQL

hi every body .
i have a important project for big organization .
this file work with SQL/PHP that php give a query and write a xml code.
The following :

<root>
         <menu id="1" sub="0" name="BENZ" />
         <menu id="2" sub="0" name="BMW" />
         <menu id="3" sub="0" name="AUDI" />

         <menu id="4" sub="1" name="classic" />
         <menu id="5" sub="1" name="avantgard" />
         <menu id="6" sub="1" name="sport" />

         <menu id="7" sub="2" name="5series" />
         <menu id="8" sub="2" name="7series" />

         <menu id="9" sub="3" name="audi tt" />
         <menu id="10" sub="3" name="audi R8" />
</root>

if sub = 0 this is root menu or main menu
if sub = 1 this is sub menu of benz or id 1
or so …

php file : “http://www.sinamoonart.com/peyvand/business.php

i can’t create this problem but i have a file for file .
just help me.
I worked on this problem, 3 weeks
thanks .