Table Business_circle
Field ID Name parent_id
1 Chaoyang 0
2 Changping 0
3 da Wang Road 1
4 Home Building 1
5 Chaoyang Park 1
$sql 1 = mysql_query ("SELECT * from Business_circle ORDER by ID ASC");
while ($rs 1 = mysql_fetch_assoc ($sql 1)) {
echo $rs 1[' name ']. $rs 1[' parent_id ']. '
';
}
The result of the recall is
Grand Lookout Road 1
Hu Jia Lou 1
Chaoyang Park 1
PARENT_ID is the ID of the parent class
I want to pull out the result is
Tai Wang Road Chaoyang
Hu Jia Lou Chao Yang
Chaoyang Park Chaoyang
Complete code should be how to write, master Help, directly to the complete code, thank you
Reply to discussion (solution)
$rs = mysql_query ("Select.name, b.name as PName from Business_circle A, business_circle b where a.parent_id = b.ID"); ($row = MYSQL_FETCH_ASSOC ($rs)) { echo $row [' name ']. ' ' . $row [' PName ']. '
';}
Big Brother upstairs thank you, but can't tune out, show blank
The great God wrote the wrong place. Help fill it up.
$rs = mysql_query ("Select A.name, B.name as PName from Business_circle A, business_circle b where a.parent_id = b.ID"); whi Le ($row = MYSQL_FETCH_ASSOC ($rs)) { echo $row [' name ']. ' ' . $row [' PName ']. '
';}
I hope I can help you.