Question
recursive iteration through recordset
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.
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.
