id mom kid
(1) earth Asia
(2) earth Europe
(3) Europe France
(4) Asia Korea
(5) earth Africa
(6) Asia China
(7) China Peking
(8) Europe Germany
(9) Germany Berlin
(10) Korea Seoul
(11) Seoul Kangnam
(12) Kangnam Hak-dong
(13) Hak-dong Hak station
(14) Asia Japan
(15) Hak station 1st floor
(16) Kangnam Seocho-dong
I have myTable like the above. and I have the code below.
$geo='Asia';
function getTableKids($mom) {
$list=mysql_query("SELECT id, mom, kid FROM myTable0 WHERE mom='$mom'");
while($rows=mysql_fetch_array($list)){$id=$rows['id'] $mom=$rows['mom'] $kid=$rows['kid']
${'mom'.$id}=$mom; ${'kid'.$id}=$kid;
echo $id.' '.$mom.' '.$kid.'[br]';
getTableKids($rows['kid']);
}
}
The result of the code above is following.
(4) Asia Korea
(10) Korea Seoul
(11) Seoul Kangnam
(12) Kangnam Hak-dong
(14) Hak-dong Hak station
(15) Hak station 1st floor
(16) Kangnam Seocho-dong
(6) Asia China
(7) China Peking
(13) Asia Japan
The result above is so cool!!!
But I like to get some variables for using them from the code above
So I add some code â${âmomâ.$id}=$mom; ${âkidâ.$id}=$kid;â which is kind of variable variables like the below.
$geo='Asia';
function getTableKids($mom) {
$list=mysql_query("SELECT id, mom, kid FROM myTable0 WHERE mom='$mom'");
while($rows=mysql_fetch_array($list)){$id=$rows['id'] $mom=$rows['mom'] $kid=$rows['kid']
${'mom'.$id}=$mom; ${'kid'.$id}=$kid;
echo $id.' '.$mom.' '.$kid.'[br]';
getTableKids($rows['kid']);
}
}
echo $mom4.' '.$kid7;
I did echo â$mom4 and $kid7â expecting the result âAsia and Pekingâ
But I canât get the value of the variables.
I hope I get the expecting result with your help?