$sql="select * from ptypes where sid = 0 and ssid =0"; $result=mysql教程_query($sql,$conn) or die("查询数据库教程出错1"); while($row=mysql_fetch_object($result)) { $i=0; $rs2=""; $sql2="select * from ptypes where sid='".$row->id."'"; $result2=mysql_query($sql2,$conn) or die("查询数据出错2"); while($row2=mysql_fetch_object($result2)) { if ($i==0){ $t=""; }else{ $t=","; } $rs2.=$t."{txt:'".$row2->title."',val:'".$row2->id."'}n"; $n=0; $rs3=""; $sql3="select * from ptypes where ssid='".$row2->id."'"; $result3=mysql_query($sql3,$conn) or die("查询是数据库出错3"); while($row3=mysql_fetch_object($result3)) { if ($n==0) { $t1=""; }else{ $t1=","; } $rs3.=$t1."{txt:'".$row3->title."',val:'".$row3->id."'}n"; $n=1; }