Web_PHP_DedeCMS_利用表单使用评论功能;
来源:互联网 发布:服饰电商运营数据分析 编辑:程序博客网 时间:2024/06/07 10:57
功能说明:利用DedeCMS自定义表单,实现在线用户评论功能;
=>表单:数据收集-数据提交-数据保存
<form name="pjform" action="/plus/diy.php" enctype="multipart/form-data" method="post"> <input type="hidden" name="action" value="post" /> <input type="hidden" name="diyid" value="1" /> <input type="hidden" name="do" value="2" /> <div class="tx_wrap">留言评价: <br /> <textarea name='lypj' id='lypj' class="tx"></textarea> </div> <div class="tj_wrap"> <div class="tj_name">昵称: <input type="text" name='hzmz' id='hzmz' class="tj_tx" /> <input type='text' name='myd' id='myd' class="tj_tx" value='0' style="display:none;" /> </div> <input type="submit" name="submit" value="提 交" class='tj_btn' style="cursor:pointer;" /> </div> <input type="hidden" name="dede_fields" value="hzmz,text;myd,int;lypj,multitext" /> <input type="hidden" name="dede_fieldshash" value="6c1e9a4f081e584e020e47fcc1ab994d" /></form>
=>页面:数据获取-数据处理-数据显示
<div><?php// 数据获取-数据处理-数据显示 // 数据获取$con = mysql_connect("localhost","root","");if (!$con){die('Could not connect: ' . mysql_error());}mysql_select_db("wjtnbdb", $con);mysql_query("SET NAMES GBK");//$result = mysql_query("SELECT * FROM dede_diyformtnbshpj WHERE ifcheck=1 order by id desc");$result = mysql_query("SELECT * FROM dede_diyformhzpj order by id desc");// 数据处理 $records = mysql_num_rows($result); //echo '->records'.$records.'<br/>'; $pagesize = 5; $pages = 0; if($records != 0 ) { switch ($records % $pagesize) { case 0: $pages = $records/$pagesize; break; case 1: case 2: case 3: case 4: $pages = floor($records/$pagesize)+1; break; } }//echo '->pagesize'.$pagesize.'<br/>';//echo '->pages'.$pages.'<br/>';// 数据显示 $cursor = 0; $ulnum=0; while($row = mysql_fetch_array($result)){ if($cursor % $pagesize == 0) { $ulnumvalue = floor($cursor / $pagesize)+1; if($ulnumvalue == 1) { $ulclass = 'style="display: block;"'; }else { $ulclass = 'style="display: none;"'; } echo '<ul id="ul'.$ulnumvalue.'" '.$ulclass.'>'; } $cursor++; echo '<li id="li'.$cursor.'">'; echo '<div class="wrap01">'; echo '<div class="name">'.$row['hzmz'].'</div>'; echo '<div class="manyidu">总体满意度:<span>★</span><span>★</span><span>★</span><span>★</span><span>★</span></div>'; echo '<div class="num">(0)</div>'; echo '<a class="zan" href="javascript:void(0);" target="_parent"></a>'; echo '</div>'; echo '<p>'.$row['lypj'].'</p>'; echo '</li>'; if($cursor % $pagesize == 0) { echo '</ul>'; } }mysql_close($con);?></div>
<div class="page"> <?php if($pages != 0) { for($num = 1; $num <= $pages; $num++) { if($num == 1) { $class = 'class="active"'; }else { $class = ''; } if($num == 1 && $pages > 1) {echo '<span id="prespan" style="cursor: pointer; display: none;"><a onclick="prepage('.$pages.');" target="_parent">上一页</a></span>';} echo '<span id="pagespan'.$num.'" style="margin: 5px;padding: 5px;border: 1px solid #CCC;"'.$class.'>'; echo '<a style="color: #666;cursor: pointer;" onclick="pagenumclick('.$num.', '.$pages.');" target="_parent">'.$num.'</a>'; echo '</span>'; if($num == $pages && $pages > 1) {echo '<span id="nextspan" style="cursor: pointer;"><a onclick="nextpage('.$pages.');" target="_parent">下一页</a></span>';} } } ?>
</div>=>js脚本:
<script type="text/javascript"> // 前者 var lastpage = 1; // 切换 function switchpage(pagenum, pages) { // 恢复前者 document.getElementById("pagespan" + lastpage).className = ""; document.getElementById("ul" + lastpage).style.display = "none"; // 保留状态 lastpage = pagenum; // 设置当下 document.getElementById("pagespan" + pagenum).className = "active"; document.getElementById("ul" + pagenum).style.display = "block"; // 显示上页 if (pagenum != 1) { document.getElementById("prespan").style.display = "inline"; } else { document.getElementById("prespan").style.display = "none"; } // 显示下页 if (pagenum == pages) { document.getElementById("nextspan").style.display = "none"; } else { document.getElementById("nextspan").style.display = "inline"; } } // 翻页 function pagenumclick(pagenum, pages) { // 切换 switchpage(pagenum, pages); } // 上页 function prepage(pages) { var pagenum = lastpage - 1; switchpage(pagenum, pages); } // 下页 function nextpage(pages) { var pagenum = lastpage + 1; switchpage(pagenum, pages); } window.onload = function () { // form dispose var formpj = document.forms["pjform"]; formpj.reset(); formpj.onsubmit = function () { var isSubmit = true; var hasError = false; var errArray = new Array(); var hzmz = document.getElementById("hzmz"); var lypj = document.getElementById("lypj"); if (hzmz.value == "") { hzmz.style.borderColor = "red"; hzmz.style.bgColor = "blue"; hzmz.title = "请输入姓名!"; hasError = true; errArray.push(hzmz); } else { hzmz.style.borderColor = ""; hzmz.style.bgColor = ""; hzmz.title = ""; hasError = false; } if (lypj.value == "") { lypj.style.borderColor = "red"; lypj.style.bgColor = "blue"; lypj.title = "请输入留言!"; hasError = true; errArray.push(lypj); } else { lypj.style.borderColor = ""; lypj.style.bgColor = ""; lypj.title = ""; hasError = false; } if (hasError && errArray.length > 0) { isSubmit = false; errArray[0].focus(); } return isSubmit; } }</script>
0 0
- Web_PHP_DedeCMS_利用表单使用评论功能;
- Web_PHP_DedeCMS_提交表单后邮件提醒功能;
- Web_PHP_DedeCMS_评论管理_点赞功能闲谈;
- Web_PHP_DedeCMS_表单验证模块;
- Web_PHP_DedeCMS_畅言评论模块操作使用说明;
- Web_PHP_DedeCMS_搜索功能实现集锦;
- Django 评论功能的使用
- Web_PHP_DedeCMS_{dede:php}标签使用;
- 利用图片实现表单功能
- Web_PHP_DedeCMS_评论留言提交、请求、点赞闲谈;
- 织梦文章评论功能的使用
- 织梦文章评论功能的使用
- Django使用forms来实现评论功能
- 使用Disqus API实现"最近评论"功能
- 评论功能
- 评论功能
- Web_PHP_DedeCMS_{dede:php}标签嵌套查询使用;
- 利用form表单实现小功能
- vs2008 IDE 环境自定义配置的导入和导出
- 新加dell服务器硬盘状态不正确问题
- 华为初级——合唱队
- paoding分词器字典目录配置
- [转]网易云音乐API分析
- Web_PHP_DedeCMS_利用表单使用评论功能;
- 黑马程序员 Java基础语法——上
- Web最新力作有奖试读获奖名单公布
- UIF的MVC模型
- el表达式获取cookie
- 获取手机上网ip
- C++编译器与链接器工作原理
- 企业常见的管理软件分类之 HR
- 常用公共函数库(验证mac地址、判断ip所属网段、创建文件夹、读取文件、获取移动客户端类型等)