In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article shows you how Thinkphp's emoticon comment responses are developed, the content is concise and easy to understand, and can definitely brighten your eyes. I hope you can get something through the details of this article.
Based on Thinkphp development of a simple emoticon comment reply example, can reply indefinitely, suitable for beginners to learn or as graduation design works.
Comment submission verification
(".submit-btn") .click (function () {var $this = $(this); var name = $this.parent (). Siblings (). Children ('.name1'). Val (); var content = $this.parent (). Siblings (). Children ('. Comment'). Val (); if (name = "" | content = "") {alert ("nickname or comment cannot be empty"); return false })
Add comment
$rules = array (/ / define dynamic validation rules array ('comment',' require', 'comment cannot be empty'), array ('username',' require', 'nickname cannot be empty'), / / array ('username',' 315 characters, 'username length must be between 3-15 digits!' , 0, 'length', 3),); $data = array (' content' = > I ("post.comment"), 'ip' = > get_client_ip (),' add_time' = > time (), 'pid' = > I (' post.pid'), 'author' = > I (' post.username'),); $comment = M ("comment") / / instantiate the User object if (! $comment- > validate ($rules)-> create ()) {/ / verify nicknames and comments exit ($comment- > getError ());} else {$add = $comment- > add ($data); if ($add) {$this- > success ('comment success');} else {$this- > error ('comment failed');}}
Comment recursive function
Function CommentList ($pid = 0, & $commentList = array (), $spac = 0) {static $I = 0; $spac = $spac + 1; / / initial level 1 comments $List = M ('comment')-> field (' id,add_time,author,content,pid')-> where (array ('pid' = > $pid))-> order ("id DESC")-> select () Foreach ($List as $k = > $v) {$commentList [$I] ['level'] = $spac; / / comment level $commentList [$I] [' author'] = $v ['author']; $commentList [$I] [' id'] = $v ['id']; $commentList [$I] [' pid'] = $v ['pid']; / / parent id of this comment $commentList [$I] [' content'] = $v ['content'] $commentList [$I] ['time'] = $v [' add_time']; / / $commentList [$I] ['pauthor'] = $pautor; $iTunes; $this- > CommentList ($v [' id'], $commentList, $spac);} return $commentList;} this is how Thinkphp's expressive comment responses are developed. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.