Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

recursive iteration through recordset

New Here ,
Jan 04, 2008 Jan 04, 2008
Hi
i have a table that i will iterate through it to generate xml using domdocument like this

<?php
$dom = new DOMDocument('1.0', 'UTF-8');
do{
if($row_Recordset1['parent_id']==0){
$element = $dom->createElement('person', $row_Recordset1['name']);
$parent=$dom->appendChild($element);
add($parent,$row_Recordset1['id']);
}
}while($row_Recordset1=mysql_fetch_assoc($Recordset1));

echo $dom->saveXML();



function add($person,$id)
{
mysql_data_seek($GLOBALS['Recordset2'],0);
do{
if($GLOBALS["row_Recordset2['parent_id']"]==$id)
{
$child=$GLOBALS['dom']->createElement('person', $GLOBALS["row_Recordset2['name']"]);
$child=$person->appendChild($child);
add($child,$GLOBALS["row_Recordset2['id']"]);
}
}while($GLOBALS['row_Recordset2']=mysql_fetch_assoc($GLOBALS['Recordset2']));
}
?>


in the above code both recordset1 and recordset2 are from the same table with same data
and the ouptput of the above code just prints the parents only although every one of those parents has childs on the hierarchy !!!!!!
father1
father2

why theh above code don't iterate through the child row?

by the way is there is a debugger for php ?i try zend but it can't debug and also try vs.php no support for domdocument !!! i need a true debugger
thanks in advance.
TOPICS
Server side applications
307
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2008 Jan 04, 2008
LATEST
got it thanks.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines