PHP无限级分类的展示问题。折腾一天了,搞不定呀
函数:
<br />//无限分类显示函数<br />function get_str($id = 0) { <br /> global $str; <br /> $sql = "select classid,classname,classstate,classtype,classurl,classpage,classorder,classtitle,classkeyword,classdescription,classpid from bz_class where classpid= $id"; <br /> $result = mysql_query($sql);//查询pid的子类的分类 <br /> if($result && mysql_affected_rows()){//如果有子类 <br /> while ($row = mysql_fetch_array($result)) { //循环记录集<br /> $str.= "<tr><td>" .$row['classid']. "</td><td>". $row['classname']. "<p>id: 882233</p>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1051">
<img src="https://img.php.cn/upload/ai_manual/001/503/042/68b6cb08a59ca496.jpeg" alt="Voicepods">
</a>
<div class="aritcle_card_info">
<a href="/ai/1051">Voicepods</a>
<p>Voicepods是一个在线文本转语音平台,允许用户在30秒内将任何书面文本转换为音频文件。</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="Voicepods">
<span>93</span>
</div>
</div>
<a href="/ai/1051" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="Voicepods">
</a>
</div>
</td><td>". $row['classtype']."</td><td>". $row['classid']."</td><td>". $row['classid']."</td><td>". $row['classid']."</td></tr>" ; //字符串构建<br /> get_str($row['classid']); //调用get_str(),将记录集中的id参数传入函数中,继续查询下级 <br /> } <br /> } <br /> return $str; <br />} <br />
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号