2级分类查询 不了解你的意思,可以说具体一点吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是说:1级主目录标题包括(树1、树2、树3)2级目录标题:树11、树12(属于树1)、树21、树22(属于树2)、树31(属于树3)如何将其标题(包括1、2目录)输出 table1:parent id title 1 树1 2 树2 3 树3 4 树4table2:child id title pid 1 树11 1 2 树12 1 3 树21 2 4 树22 2 5 树31 3程序代码如下:<?include "include.php";//引用数据库连接的文件$mysql=new message;//创建数据库连接的类$mysql->link();$mysql->sqllink;$mysql->selectdata;$query1=mysql_query("select * from parent");//$query2=mysql_query("select * from child");$getid=$_GET['id'];$query2=mysql_query("select * from child where pid='$getid'");?><table width="200" border="1" align="center" cellpadding="0" cellspacing="0"><?while($fetch1=mysql_fetch_array($query1)){ $ptitle=$fetch1["title"]; $id=$fetch1["id"]; echo "<tr><td><a href='class.php?id=$id'>$ptitle</a></td></tr>"; if(!$query2){ break; } while($fetch2=mysql_fetch_array($query2)){ $ctitle=$fetch2["title"]; echo "<tr><td>$ctitle</td></tr>"; } }?></table>输出时属于树2、树3的子类却显示在树1下,我要是属于树1的子类显示在树1下,属于树2的子类显示在树2下,如此类推.如何改了?谢了 那位高手能指点一下小弟呢.感激不尽 咱也学着创业 求救 如何通过程序判定php运行所需版本啊? PHP mysql_fetch_array 使用问题 换行问题 mysql的问题 ???数组的问题??? 很简单 的估计是 配置问题? 求助,之前安装的SQL server删除不了,怎么办? yii2.0 遍历加弹窗怎么做 这些PHP代码,和JavaScript做某种结合后,网页不能正确显示的问题 用php上传文件时候怎样在子页面里的值返回到父页面问题?
2级目录标题:树11、树12(属于树1)、树21、树22(属于树2)、树31(属于树3)如何将其标题(包括1、2目录)输出
id title
1 树1
2 树2
3 树3
4 树4
table2:child
id title pid
1 树11 1
2 树12 1
3 树21 2
4 树22 2
5 树31 3
程序代码如下:<?
include "include.php";//引用数据库连接的文件
$mysql=new message;//创建数据库连接的类
$mysql->link();
$mysql->sqllink;
$mysql->selectdata;$query1=mysql_query("select * from parent");
//$query2=mysql_query("select * from child");
$getid=$_GET['id'];
$query2=mysql_query("select * from child where pid='$getid'");?>
<table width="200" border="1" align="center" cellpadding="0" cellspacing="0">
<?
while($fetch1=mysql_fetch_array($query1)){
$ptitle=$fetch1["title"];
$id=$fetch1["id"];
echo "<tr><td><a href='class.php?id=$id'>$ptitle</a></td></tr>";
if(!$query2){
break;
}
while($fetch2=mysql_fetch_array($query2)){
$ctitle=$fetch2["title"];
echo "<tr><td>$ctitle</td></tr>";
}
}
?>
</table>输出时属于树2、树3的子类却显示在树1下,我要是属于树1的子类显示在树1下,属于树2的子类显示在树2下,如此类推.
如何改了?
谢了
感激不尽