搜索
首页后端开发php教程 PHP SMARTY 双循环(递归)输出分类 有关问题

PHP SMARTY 双循环(递归)输出分类 问题
模版

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->{foreach from=$classlist item=newsclass}
    <div class="bg03"><a href="news.php?classid=%7B%24newsclass.id%7D&%7Bif%20%24newsclass.ispro%20eq%201%7Dispro=true%7B/if%7D" target="main">{$newsclass.classname}</a></div>
{/foreach}


程序
PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->$sql = "select * from jh_newsclass where parentid = 0";
$result = $mysqli->query($sql);
while ($row = $result->fetch_row()) {
    $classlist[] = array(
        'id'=>$row[0],
        'classname'=>$row[2],
        'parentid'=>$row[1],
        'ispro'=>$row[3],    
        );
}
$result->close();
$mysqli->close();
$smarty->assign('classlist',$classlist);
$smarty->assign('webname',Webname);
$smarty->display('admin/left.htm');




这样只能输出一级分类. 我需要在一级分类下再输出二级..三级..该怎么写呀? 


以前用ASP输出的效果
HTML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->              <div class="bg03">新闻专题</div>
<div class="forumlist_groups"><div align="left"><ul>
<li class="forumli"><a href="news.asp?classid=3&newsclass=3" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">新闻动态</font></a></li>
<li class="forumli"><a href="news.asp?classid=6&newsclass=6" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">美大专题</font></a></li>
<li class="forumli"><a href="news.asp?classid=16&newsclass=16" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">月兔专题</font></a></li>
</ul></div></div>

    <div class="bg03"><a href="news.asp?classid=14&newsclass=14" target="main">供求信息</a></div>

              <div class="bg03">产品展示</div>
<div class="forumlist_groups"><div align="left"><ul>
<li class="forumli"><a href="news.asp?classid=18&ispro=true&newsclass=18" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">美大灶具</font></a></li>
<li class="forumli"><a href="news.asp?classid=19&ispro=true&newsclass=19" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">月图厨柜</font></a></li>
<li class="forumli"><a href="news.asp?classid=20&ispro=true&newsclass=20" target="main">+--<img  src="/static/imghwm/default1.png" data-src="images/leaf.gif" class="lazy" id="folder180"    style="max-width:90%"  style="max-width:90%" align="absmiddle" alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">集成效果</font></a></li>
</ul></div></div>



原来的ASP代码 
HTML code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->






    <div class="bg03"><a href="news.php?classid=<%=rs(" id>&newsclass=" target="main"></a></div>

              <div class="bg03"></div>

        

<div align="left"><ul>")
        while not showparentclassrs.eof

            response.Write"<li class="" forumli>"
            set temprs = conn.execute("select * from Jh_newsclass where parentid = " & showparentclassrs("id"))
            if temprs.eof and temprs.bof then
                response.Write"<a href="news.php?classid=%22&showparentclassrs(%22id%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20showparentclassrs(%22ispro%22)%20then%20response.Write(%22&ispro=true%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20response.Write%22&newsclass=%22&showparentclassrs(%22id%22)&%22" target="main">" & astr & tree & "<img  src="/static/imghwm/default1.png" data-src="" images class="lazy" id="" folder180    style="max-width:90%" height="" align="" absmiddle alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " ><font color="">" & showparentclassrs("classname")&"</font></a>"
            else
                response.Write astr & tree & "<img  src="/static/imghwm/default1.png" data-src="" images class="lazy" id="" folder180    style="max-width:90%" height="" align="" absmiddle alt=" PHP SMARTY 双循环(递归)输出分类 有关问题 " >" & showparentclassrs("classname")
            end if
            set temprs = nothing
            response.Write"</li>"


            call showparentclass(astr,tree&"--",showparentclassrs("id"))
        showparentclassrs.movenext
        wend
    response.Write("</ul></div>")
    end if
end sub
%>
 <div class="clear">
                 
              
              
        
            </div>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
绝对会话超时有什么区别?绝对会话超时有什么区别?May 03, 2025 am 12:21 AM

绝对会话超时从会话创建时开始计时,闲置会话超时则从用户无操作时开始计时。绝对会话超时适用于需要严格控制会话生命周期的场景,如金融应用;闲置会话超时适合希望用户长时间保持会话活跃的应用,如社交媒体。

如果会话在服务器上不起作用,您将采取什么步骤?如果会话在服务器上不起作用,您将采取什么步骤?May 03, 2025 am 12:19 AM

服务器会话失效可以通过以下步骤解决:1.检查服务器配置,确保会话设置正确。2.验证客户端cookies,确认浏览器支持并正确发送。3.检查会话存储服务,如Redis,确保其正常运行。4.审查应用代码,确保会话逻辑正确。通过这些步骤,可以有效诊断和修复会话问题,提升用户体验。

session_start()函数的意义是什么?session_start()函数的意义是什么?May 03, 2025 am 12:18 AM

session_start()iscucialinphpformanagingusersessions.1)ItInitiateSanewsessionifnoneexists,2)resumesanexistingsessions,and3)setsasesessionCookieforContinuityActinuityAccontinuityAcconActInityAcconActInityAcconAccRequests,EnablingApplicationsApplicationsLikeUseAppericationLikeUseAthenticationalticationaltication and PersersonalizedContentent。

为会话cookie设置httponly标志的重要性是什么?为会话cookie设置httponly标志的重要性是什么?May 03, 2025 am 12:10 AM

设置httponly标志对会话cookie至关重要,因为它能有效防止XSS攻击,保护用户会话信息。具体来说,1)httponly标志阻止JavaScript访问cookie,2)在PHP和Flask中可以通过setcookie和make_response设置该标志,3)尽管不能防范所有攻击,但应作为整体安全策略的一部分。

PHP会议在网络开发中解决了什么问题?PHP会议在网络开发中解决了什么问题?May 03, 2025 am 12:02 AM

phpsessions solvathepromblymaintainingStateAcrossMultipleHttpRequestsbyStoringDataTaNthEserVerAndAssociatingItwithaIniquesestionId.1)他们储存了AtoredAtaserver side,通常是Infilesordatabases,InseasessessionIdStoreDistordStoredStoredStoredStoredStoredStoredStoreDoreToreTeReTrestaa.2)

可以在PHP会话中存储哪些数据?可以在PHP会话中存储哪些数据?May 02, 2025 am 12:17 AM

phpsessionscanStorestrings,数字,数组和原始物。

您如何开始PHP会话?您如何开始PHP会话?May 02, 2025 am 12:16 AM

tostartaphpsession,usesesses_start()attheScript'Sbeginning.1)placeitbeforeanyOutputtosetThesessionCookie.2)useSessionsforuserDatalikeloginstatusorshoppingcarts.3)regenerateSessiveIdStopreventFentfixationAttacks.s.4)考虑使用AttActAcks.s.s.4)

什么是会话再生,如何提高安全性?什么是会话再生,如何提高安全性?May 02, 2025 am 12:15 AM

会话再生是指在用户进行敏感操作时生成新会话ID并使旧ID失效,以防会话固定攻击。实现步骤包括:1.检测敏感操作,2.生成新会话ID,3.销毁旧会话ID,4.更新用户端会话信息。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用

螳螂BT

螳螂BT

Mantis是一个易于部署的基于Web的缺陷跟踪工具,用于帮助产品缺陷跟踪。它需要PHP、MySQL和一个Web服务器。请查看我们的演示和托管服务。

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Atom编辑器mac版下载

Atom编辑器mac版下载

最流行的的开源编辑器