Chinaunix首页 | 论坛 | 博客
  • 博客访问: 693525
  • 博文数量: 143
  • 博客积分: 1554
  • 博客等级: 上尉
  • 技术积分: 1767
  • 用 户 组: 普通用户
  • 注册时间: 2011-04-10 11:50
文章分类

全部博文(143)

文章存档

2017年(2)

2016年(5)

2015年(16)

2014年(25)

2013年(27)

2012年(16)

2011年(52)

分类: PHP

2014-09-15 11:29:19

1. PHP页面显示

点击(此处)折叠或打开

  1. <?php
  2. /**
  3.  * @author sendy
  4.  * @copyright 2014
  5.  */
  6. header("content-type:text/html;charset=utf-8");
  7. include 'login_ok.php';
  8. require "libs/Smarty.class.php";
  9. include 'dbconn.php';
  10. $smarty = new Smarty();
  11. $sql="select id,menutype,classid,username from super_type where classid=0";
  12. $stmt = $dbh->prepare($sql);
  13. $stmt->execute();
  14. $res = $stmt->fetchAll(PDO::FETCH_ASSOC);
  15. //var_dump($res);
  16. foreach($res as $rows){
  17.     $classid1[] = $rows;
  18.     $sql2="select id,menutype,classid,username from super_type where classid=".$rows['id'];
  19.     $stmt = $dbh->prepare($sql2);
  20.     $stmt->execute();
  21.     $ress = $stmt->fetchAll(PDO::FETCH_ASSOC);
  22.         foreach($ress as $rowss){
  23.             $classid2[] = $rowss;
  24.         }
  25.    // var_dump($classid2);
  26.    //exit;
  27.     $smarty->assign("classid2",$classid2);
  28. }
  29. //$smarty = new Smarty();
  30. $smarty -> assign("res",$res);
  31. $smarty -> display("menu.html");
  32. ?>
2.HTML页面显示

点击(此处)折叠或打开

  1. <body>
  2.     
  3.     <ul>
  4.         {section name=line loop=$res}
  5.              <li>
  6.                      <a href="message.php?title={$res[line].id}" target="main"><p>{$res[line].menutype}</p>

  7.                <ul>
  8.                     {section name=list loop=$classid2}
  9.                         {if $res[line].id == $classid2[list].classid}
  10.                             <li>
  11.                             <a href="message.php?title={$classid2[list].id}" target="main"><p>{$classid2[list].menutype}</p></a>
  12.                             </li>
  13.                         {/if}
  14.                     {/section}
  15.                </ul>
  16.             </li>
  17.       {/section}
  18.     </ul>

  19.         
  20.         <a href="add.html" target="main">添加</a>
  21.    

  22. </body>
3.示例图显示


阅读(1201) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~