做了一个无限评论,不知道咋样

无限评论html<style> {literal} *{ margin: 0 auto} h3{border:1px #999 solid; height:30px; 780px;} .nr{ text-indent:2em;} {/literal} </style> </head> <body> <div

无限评论
html

  1. <style>
  2. {literal}
  3. *{ margin: 0 auto}
  4. h3{border:1px #999 solid; height:30px; 780px;}
  5. .nr{ text-indent:2em;}
  6. {/literal}
  7. </style>
  8. </head>
  9. <body>
  10. <div style="width:800px; padding:10px; border:1px #999 solid;">
  11.     <h3>{$info.title}</h3>
  12.     <div class="nr">{$info.con}</div>
  13. </div>
  14. <div>
  15.  <div style="border-bottom:1px #999 solid; 800px; margin-bottom:10px;">热门评论</div>
  16.  {foreach $pl as $k => $vv}
  17.  <div style="border:1px #999 solid; 800px;">
  18.      <div style="padding:8px;">{$vv.con}</div>
  19.     
  20.      {foreach $hpl as $k=>$h}
  21.         {if $vv.id == $h.fid}
  22.           <div style="text-align:right">{$h.con} <span class="hf_a">回复 {$h.fid}</span></div>
  23.          
  24.         {/if}
  25.         
  26.      {/foreach}
  27.       <div style="text-align:right" class="hf_b">
  28.       <form action="{U('index/add')}" method="post">
  29.       <input type="hidden" name="fid" value="{$vv.id}" />
  30.       <input type="hidden" name="nid"  value="{$info.id}"/>
  31.       <input type="text" name="con" />
  32.       <input type="submit" value="评论" />
  33.       </form>
  34.       </div>
  35.  </div>
  36.  {/foreach}
  37.  
  38. </div>
  39. <div style="width:800px; padding:10px; border:1px #999 solid; margin-top:8px;">
  40. <form action="{U('index/add')}" method="post">
  41. <input type="hidden" name="fid" value="0" />
  42. <input type="hidden" name="nid"  value="{$info.id}"/>
  43. <input type="text" name="con" />
  44. <input type="submit" value="评论" />
  45. </form>
  46. </div>
  47. </body>
  48. </html>
复制

Controller

  1. namespace HomeController;
  2. use ThinkController;
  3. class IndexController extends Controller {
  4.     public function index(){
  5.         $info=M('neirong')->find();
  6.         $pid=$info['id'];
  7.         $pl=M('pinlun')->where("nid = $pid and fid=0")->select();
  8.         $hpl=M('pinlun')->where("nid = $pid")->select();
  9.         $this->assign("info",$info);
  10.         $this->assign("pl",$pl);
  11.         $this->assign("hpl",$hpl);
  12.         
  13.        $this->display();
  14.     }
  15.      public function add(){
  16.          $data=I('post.');
  17.     $pl=M('pinlun')->add($data);
  18.          
  19.      }
复制


原文地址:https://www.cnblogs.com/ZDPPU/p/5823815.html