在Discuz! X3.4和X3.5的开发中,掌握常用的函数和模板调用方法是非常重要的。以下是一些常见的操作和代码示例,帮助你更好地理解和使用Discuz!的开发手册。
1. 数据库操作
调用单个数据- $a = DB::result(DB::query("SELECT qi FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码- DB::table('abc'):获取带前缀的表名。
- DB::query():执行SQL查询。
- DB::result():获取查询结果的第一个字段值。
调用统计数据- $a = DB::result(DB::query("SELECT count(*) FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码
单数据表调用- $perpage = 20;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $askcount = DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table('forum_thread')." WHERE fid = '2' AND authorid > 1"));
- $asklist = array();
- if ($askcount) {
- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2' AND displayorder > -1 ORDER BY tid ASC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $asklist[] = $value;
- }
- }
- $multi = multi($askcount, $perpage, $curpage, "这里填写跳转地址");
复制代码
多数据表调用- $perpage = 40;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $acount = DB::result(DB::query("SELECT count(*) FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != ''"));
- $alist = array();
- if ($acount) {
- $query = DB::query("SELECT bf.*, b.* FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != '' ORDER BY bf.shoplevel DESC, b.commoncredits DESC, bf.fid DESC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $alist[] = $value;
- }
- }
- $multi = multi($acount, $perpage, $curpage, "这里填写跳转地址");
复制代码
2. 表单提交与数据处理
表单提交- <form method="post" action="">
- 最低奖金:<input type="text" name="min_bonus" />
- 最高奖金:<input type="text" name="max_bonus" />
- <input type="submit" name="submit" value="提交设置" />
- </form>
复制代码
数据处理- if (submitcheck('submit')) {
- $min_bonus = intval($_POST['min_bonus']);
- $max_bonus = intval($_POST['max_bonus']);
-
- $setarr = array(
- 'min_bonus' => $min_bonus,
- 'max_bonus' => $max_bonus,
- 'dateline' => TIMESTAMP,
- );
-
- DB::insert('bonus_settings', $setarr, true);
- showmessage('设置成功', 'forum.php');
- }
复制代码
3. 模板调用与显示
前台数据显示- foreach ($asklist as $value) {
- echo $value['subject'];
- }
复制代码
人性化时间戳- echo dgmdate($value['dateline'], 'Y-m-d H:i:s');
复制代码
截取字符字数- echo cutstr($value['message'], 100);
复制代码
4. 其他常用操作
过滤DISCUZ代码- $message = preg_replace("/\[.*?\]/i", '', $message);
复制代码
写入数据库- if (submitcheck('tijiao')) {
- $setarr = array(
- 'tid' => $_GET['tid'],
- 'name' => $_POST['name'],
- 'position' => $_GET['position'],
- 'dateline' => TIMESTAMP,
- );
- DB::insert('abc', $setarr, true);
- showmessage('操作成功', 'forum.php');
- }
复制代码
更新数据库- $setarr = array(
- 'uid' => $uid,
- 'name' => $name,
- 'url' => $url,
- 'datatime' => TIMESTAMP,
- );
- DB::update('peach_webmaster', $setarr, "uid='$uid'");
复制代码
删除数据- DB::delete('abc', "id='$id'");
复制代码
5. 模板中嵌入PHP代码- <!--{eval echo 'dz插件网';}-->
复制代码
6. JS操作
JS跳转- <button onclick="window.location.href='home.php?mod=mobile&do=friend';">跳转</button>
复制代码
JS更换class名称- <div id="idname" class="oldclass">内容</div>
- <button onclick="document.getElementById('idname').className='newclass';">更换class</button>
复制代码
批量替换超链接- var links = document.querySelectorAll('a');
- links.forEach(function(link) {
- link.href = link.href.replace('oldurl', 'newurl');
- });
复制代码
7. 其他常用函数
获取数组- $a = DB::fetch_all("SELECT title FROM ".DB::table('abc')." WHERE uid = '".$uid."'");
复制代码
获取对应数据表中一条数据的值- $a = DB::fetch_first("SELECT * FROM ".DB::table('abc')." WHERE id = '".$id."'");
复制代码
统计数据返回为int- $a = DB::result(DB::query("SELECT count(*) FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码
8. 时间格式转换- echo date("Y-m-d H:i:s", $value['dateline']);
复制代码
9. 调用图片附件- $attachment = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'image');
- foreach ($attachment as $attach) {
- echo '<img src="' . $attach['url'] . '" />';
- }
复制代码
10. 数据库循环嵌套调用- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2'");
- while ($thread = DB::fetch($query)) {
- $post_query = DB::query("SELECT * FROM ".DB::table('forum_post')." WHERE tid = '".$thread['tid']."'");
- while ($post = DB::fetch($post_query)) {
- echo $post['message'];
- }
- }
复制代码
11. UCenter无法登录的解决方法- // 打开 uc_server/model/admin.php
- // 找到第22行的
- $this->cookie_status = 0;
- // 改成
- $this->cookie_status = isset($_COOKIE['sid']) ? 1 : 0;
复制代码
12. 无刷新切换li标签并且同时加载框架页面- var jq = jQuery.noConflict();
- jq(function(){
- jq("#changemenu>li").mouseover(function(){
- jq("#changemenu>li").each(function(i){
- jq(this).removeClass("current");
- });
- jq(this).addClass("current");
- document.getElementById("changenr").innerHTML='';
- }).mouseout(function(){
- jq(this).addClass("current");
- });
- });
复制代码
13. 快速发帖发布新话题- if (submitcheck('topicsubmit')) {
- $subject = $_POST['subject'];
- $message = $_POST['message'];
- $fid = $_GET['fid'];
-
- $tid = C::t('forum_thread')->insert_thread(array(
- 'fid' => $fid,
- 'subject' => $subject,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'dateline' => TIMESTAMP,
- ));
-
- C::t('forum_post')->insert_post(array(
- 'tid' => $tid,
- 'fid' => $fid,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'message' => $message,
- 'dateline' => TIMESTAMP,
- ));
-
- showmessage('发帖成功', "forum.php?mod=viewthread&tid=$tid");
- }
复制代码
14. DISCUZ JSON数据解析获取- $str = 'a:2:{s:8:"sitename";s:8:"dz插件网";s:3:"pic";s:12:"ymg6.jpg";}';
- $newstr = str_replace("\", "", $str);
- $data = unserialize($newstr);
- echo $data['sitename']; // 输出结果为 dz插件网
复制代码
15. LI标签列表自适应宽度JS实现代码- <style>
- ul, li {margin: 0; padding: 0; list-style: none;}
- .list {width: 100%; margin: 0 auto;}
- .list li {width: 32%; float: left; margin-right: 2%; background: #0092B9; text-align: center; color: #fff; height: 300px; line-height: 300px; margin-bottom: 10px;}
- </style>
- <ul class="list">
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- </ul>
- <script>
- $('.list li:nth-child(3n)').css('marginRight', '0');
- </script>
复制代码
16. 常用词汇
- select:选择
- count:总数
- table:表
- where:条件
- result:结果
- perpage:每页
- curpage:当前页
- update:更新
- delete:删除
- insert:写入
- dateline:日期
- time:时间
- echo:输出
- multi:分页函数
- if:如果
- else:否则
- elseif:否则如果
- start:起始
- limit:限制
- DESC:倒序
- ASC:正序
17. 活动帖发布页面核心处理文件- // source/class/extend/extend_thread_activity.php
复制代码
18. 分类信息解析文件- // source/function/function_threadsort.php
复制代码
19. 模板中运行PHP代码- <!--{eval echo 'dz插件网';}-->
复制代码
20. 标签获得焦点后触发- <input type="text" onfocus="ymgcom()" />
复制代码
21. 标签失去焦点后触发- <input type="text" onblur="ymgcom()" />
复制代码
22. 密码输出- $password = preg_replace("/^(.{".round(strlen($_GET['password']) / 4)."})(.+?)(.{".round(strlen($_GET['password']) / 6)."})$/s", "\\1***\\3", $_GET['password']);
- echo $password; // 输出 1*****6
复制代码
23. 获取数组- $a = DB::fetch_all("SELECT title FROM ".DB::table('abc')." WHERE uid = '".$uid."'");
复制代码
24. 获取对应数据表中一条数据的值- $a = DB::fetch(DB::query("SELECT * FROM ".DB::table('abc')." WHERE id = '".$id."'"));
复制代码
25. 统计数据返回为int- $a = DB::result(DB::query("SELECT count(*) FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码
26. 写入数据- DB::insert('abc', $setarr, true);
复制代码
27. 更新数据- DB::update('abc', $setarr, "id='$id'");
复制代码
28. 删除数据- DB::delete('abc', "id='$id'");
复制代码
29. 其他数据库方法- DB::table($table); // 获取带前缀的表名
- DB::insert_id(); // 返回插入的自增长ID
- DB::fetch_first($sql); // 取查询的第一条数据
- DB::fetch_all($sql); // 查询并fetch
- DB::result_first($sql); // 查询结果集的第一个字段值
- DB::query($sql); // 普通查询
- DB::limit($start, $limit); // limit条件
- DB::order($field, $order); // 返回排序
- DB::field($field, $val); // 返回字段条件
复制代码
30. 插件新增的目录使用方法- // source/plugin/mypluginid/table/table_mytablename.php
- // 使用类名称:table_mytablename
- // 使用最佳时间:C::t('#mypluginid#mytablename')->method();
复制代码
31. 数据库常用方法- C::t('tablename')->method();
复制代码
32. 调用单条数据- $qishi = DB::result(DB::query("SELECT qi FROM ".DB::table('jiangchi')." WHERE id = '1'"));
复制代码
33. 调用统计数据- $qishi = DB::result(DB::query("SELECT count(*) FROM ".DB::table('jiangchi')." WHERE id = '1'"));
复制代码
34. 单数据表调用- $perpage = 20;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $askcount = DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table('forum_thread')." WHERE fid = '2' AND authorid > 1 AND FROM_UNIXTIME(dateline, '%Y%m%d') = '$jintian'"));
- $asklist = array();
- if ($askcount) {
- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2' AND displayorder > -1 ORDER BY tid ASC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $asklist[] = $value;
- }
- }
- $multi = multi($askcount, $perpage, $curpage, "portal.php?mod=topic&topic=ask");
复制代码
35. 获取数组- $add = DB::fetch_first("SELECT * FROM ".DB::table('peach_webmaster')." WHERE uid=".$uid);
复制代码
36. 多数据表调用- $perpage = 40;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $acount = DB::result(DB::query("SELECT count(*) FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != ''"));
- $alist = array();
- if ($acount) {
- $query = DB::query("SELECT bf.*, b.* FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != '' ORDER BY bf.shoplevel DESC, b.commoncredits DESC, bf.fid DESC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $alist[] = $value;
- }
- }
- $multi = multi($acount, $perpage, $curpage, "这里填写跳转地址");
复制代码
37. 前台数据显示- foreach ($value as $item) {
- echo $item['field'];
- }
复制代码
38. 人性化时间- echo dgmdate($value['dateline'], 'Y-m-d H:i:s');
复制代码
39. 截取字符数- echo cutstr($value['message'], 100);
复制代码
40. 写入数据库- if (submitcheck('tijiao')) {
- $setarr = array(
- 'tid' => $_GET['tid'],
- 'name' => $_POST['name'],
- 'position' => $_GET['position'],
- 'dateline' => TIMESTAMP,
- );
- DB::insert('forum_poststick', $setarr, true);
- $query = DB::query("UPDATE ".DB::table('forum_thread')." SET stickreply='1' WHERE tid='$tid'");
- $query = DB::query("DELETE FROM ".DB::table('forum_post')." WHERE pid='$pid'");
- showmessage('成功的提示信息', "forum.php?mod=viewthread&tid=$tid");
- }
复制代码
41. 更新数据库- $setarr = array(
- 'uid' => $uid,
- 'name' => $name,
- 'url' => $url,
- 'datatime' => TIMESTAMP,
- );
- DB::update('peach_webmaster', $setarr, "uid='$uid'");
复制代码
42. 表单提交- <form method="post" action="">
- 最低奖金:<input type="text" name="min_bonus" />
- 最高奖金:<input type="text" name="max_bonus" />
- <input type="submit" name="submit" value="提交设置" />
- </form>
复制代码
43. 时间格式转换- echo date("Y-m-d H:i:s", $value['dateline']);
复制代码
44. 调用图片附件- $attachment = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'image');
- foreach ($attachment as $attach) {
- echo '<img src="' . $attach['url'] . '" />';
- }
复制代码
45. 数据库循环嵌套调用- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2'");
- while ($thread = DB::fetch($query)) {
- $post_query = DB::query("SELECT * FROM ".DB::table('forum_post')." WHERE tid = '".$thread['tid']."'");
- while ($post = DB::fetch($post_query)) {
- echo $post['message'];
- }
- }
复制代码
46. UCenter无法登录的解决方法- // 打开 uc_server/model/admin.php
- // 找到第22行的
- $this->cookie_status = 0;
- // 改成
- $this->cookie_status = isset($_COOKIE['sid']) ? 1 : 0;
复制代码
47. 无刷新切换li标签并且同时加载框架页面- var jq = jQuery.noConflict();
- jq(function(){
- jq("#changemenu>li").mouseover(function(){
- jq("#changemenu>li").each(function(i){
- jq(this).removeClass("current");
- });
- jq(this).addClass("current");
- document.getElementById("changenr").innerHTML='';
- }).mouseout(function(){
- jq(this).addClass("current");
- });
- });
复制代码
48. 快速发帖发布新话题- if (submitcheck('topicsubmit')) {
- $subject = $_POST['subject'];
- $message = $_POST['message'];
- $fid = $_GET['fid'];
-
- $tid = C::t('forum_thread')->insert_thread(array(
- 'fid' => $fid,
- 'subject' => $subject,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'dateline' => TIMESTAMP,
- ));
-
- C::t('forum_post')->insert_post(array(
- 'tid' => $tid,
- 'fid' => $fid,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'message' => $message,
- 'dateline' => TIMESTAMP,
- ));
-
- showmessage('发帖成功', "forum.php?mod=viewthread&tid=$tid");
- }
复制代码
49. DISCUZ JSON数据解析获取- $str = 'a:2:{s:8:"sitename";s:8:"dz插件网";s:3:"pic";s:12:"ymg6.jpg";}';
- $newstr = str_replace("\", "", $str);
- $data = unserialize($newstr);
- echo $data['sitename']; // 输出结果为 dz插件网
复制代码
50. LI标签列表自适应宽度JS实现代码- <style>
- ul, li {margin: 0; padding: 0; list-style: none;}
- .list {width: 100%; margin: 0 auto;}
- .list li {width: 32%; float: left; margin-right: 2%; background: #0092B9; text-align: center; color: #fff; height: 300px; line-height: 300px; margin-bottom: 10px;}
- </style>
- <ul class="list">
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- </ul>
- <script>
- $('.list li:nth-child(3n)').css('marginRight', '0');
- </script>
复制代码
51. 常用词汇
- select:选择
- count:总数
- table:表
- where:条件
- result:结果
- perpage:每页
- curpage:当前页
- update:更新
- delete:删除
- insert:写入
- dateline:日期
- time:时间
- echo:输出
- multi:分页函数
- if:如果
- else:否则
- elseif:否则如果
- start:起始
- limit:限制
- DESC:倒序
- ASC:正序
52. 活动帖发布页面核心处理文件- // source/class/extend/extend_thread_activity.php
复制代码
53. 分类信息解析文件- // source/function/function_threadsort.php
复制代码
54. 模板中运行PHP代码- <!--{eval echo 'dz插件网';}-->
复制代码
55. 标签获得焦点后触发- <input type="text" onfocus="ymgcom()" />
复制代码
56. 标签失去焦点后触发- <input type="text" onblur="ymgcom()" />
复制代码
57. 密码输出- $password = preg_replace("/^(.{".round(strlen($_GET['password']) / 4)."})(.+?)(.{".round(strlen($_GET['password']) / 6)."})$/s", "\\1***\\3", $_GET['password']);
- echo $password; // 输出 1*****6
复制代码
58. 获取数组- $a = DB::fetch_all("SELECT title FROM ".DB::table('abc')." WHERE uid = '".$uid."'");
复制代码
59. 获取对应数据表中一条数据的值- $a = DB::fetch(DB::query("SELECT * FROM ".DB::table('abc')." WHERE id = '".$id."'"));
复制代码
60. 统计数据返回为int- $a = DB::result(DB::query("SELECT count(*) FROM ".DB::table('abc')." WHERE id = '1'"));
复制代码
61. 写入数据- DB::insert('abc', $setarr, true);
复制代码
62. 更新数据- DB::update('abc', $setarr, "id='$id'");
复制代码
63. 删除数据- DB::delete('abc', "id='$id'");
复制代码
64. 其他数据库方法- DB::table($table); // 获取带前缀的表名
- DB::insert_id(); // 返回插入的自增长ID
- DB::fetch_first($sql); // 取查询的第一条数据
- DB::fetch_all($sql); // 查询并fetch
- DB::result_first($sql); // 查询结果集的第一个字段值
- DB::query($sql); // 普通查询
- DB::limit($start, $limit); // limit条件
- DB::order($field, $order); // 返回排序
- DB::field($field, $val); // 返回字段条件
复制代码
65. 插件新增的目录使用方法- // source/plugin/mypluginid/table/table_mytablename.php
- // 使用类名称:table_mytablename
- // 使用最佳时间:C::t('#mypluginid#mytablename')->method();
复制代码
66. 数据库常用方法- C::t('tablename')->method();
复制代码
67. 调用单条数据- $qishi = DB::result(DB::query("SELECT qi FROM ".DB::table('jiangchi')." WHERE id = '1'"));
复制代码
68. 调用统计数据- $qishi = DB::result(DB::query("SELECT count(*) FROM ".DB::table('jiangchi')." WHERE id = '1'"));
复制代码
69. 单数据表调用- $perpage = 20;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $askcount = DB::result(DB::query("SELECT COUNT(*) FROM ".DB::table('forum_thread')." WHERE fid = '2' AND authorid > 1 AND FROM_UNIXTIME(dateline, '%Y%m%d') = '$jintian'"));
- $asklist = array();
- if ($askcount) {
- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2' AND displayorder > -1 ORDER BY tid ASC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $asklist[] = $value;
- }
- }
- $multi = multi($askcount, $perpage, $curpage, "portal.php?mod=topic&topic=ask");
复制代码
70. 获取数组- $add = DB::fetch_first("SELECT * FROM ".DB::table('peach_webmaster')." WHERE uid=".$uid);
复制代码
71. 多数据表调用- $perpage = 40;
- $curpage = empty($_GET['page']) ? 1 : intval($_GET['page']);
- $start = ($curpage - 1) * $perpage;
- $acount = DB::result(DB::query("SELECT count(*) FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != ''"));
- $alist = array();
- if ($acount) {
- $query = DB::query("SELECT bf.*, b.* FROM ".DB::table('forum_forum')." b LEFT JOIN ".DB::table('forum_forumfield')." bf ON bf.fid=b.fid WHERE b.type='sub' AND b.status = 3 AND bf.icon != '' ORDER BY bf.shoplevel DESC, b.commoncredits DESC, bf.fid DESC LIMIT $start,$perpage");
- while ($value = DB::fetch($query)) {
- $alist[] = $value;
- }
- }
- $multi = multi($acount, $perpage, $curpage, "这里填写跳转地址");
复制代码
72. 前台数据显示- foreach ($value as $item) {
- echo $item['field'];
- }
复制代码
73. 人性化时间- echo dgmdate($value['dateline'], 'Y-m-d H:i:s');
复制代码
74. 截取字符数- echo cutstr($value['message'], 100);
复制代码
75. 写入数据库- if (submitcheck('tijiao')) {
- $setarr = array(
- 'tid' => $_GET['tid'],
- 'name' => $_POST['name'],
- 'position' => $_GET['position'],
- 'dateline' => TIMESTAMP,
- );
- DB::insert('forum_poststick', $setarr, true);
- $query = DB::query("UPDATE ".DB::table('forum_thread')." SET stickreply='1' WHERE tid='$tid'");
- $query = DB::query("DELETE FROM ".DB::table('forum_post')." WHERE pid='$pid'");
- showmessage('成功的提示信息', "forum.php?mod=viewthread&tid=$tid");
- }
复制代码
76. 更新数据库- $setarr = array(
- 'uid' => $uid,
- 'name' => $name,
- 'url' => $url,
- 'datatime' => TIMESTAMP,
- );
- DB::update('peach_webmaster', $setarr, "uid='$uid'");
复制代码
77. 表单提交- <form method="post" action="">
- 最低奖金:<input type="text" name="min_bonus" />
- 最高奖金:<input type="text" name="max_bonus" />
- <input type="submit" name="submit" value="提交设置" />
- </form>
复制代码
78. 时间格式转换- echo date("Y-m-d H:i:s", $value['dateline']);
复制代码
79. 调用图片附件- $attachment = C::t('forum_attachment_n')->fetch_all_by_id('tid:' . $tid, 'image');
- foreach ($attachment as $attach) {
- echo '<img src="' . $attach['url'] . '" />';
- }
复制代码
80. 数据库循环嵌套调用- $query = DB::query("SELECT * FROM ".DB::table('forum_thread')." WHERE fid = '2'");
- while ($thread = DB::fetch($query)) {
- $post_query = DB::query("SELECT * FROM ".DB::table('forum_post')." WHERE tid = '".$thread['tid']."'");
- while ($post = DB::fetch($post_query)) {
- echo $post['message'];
- }
- }
复制代码
81. UCenter无法登录的解决方法- // 打开 uc_server/model/admin.php
- // 找到第22行的
- $this->cookie_status = 0;
- // 改成
- $this->cookie_status = isset($_COOKIE['sid']) ? 1 : 0;
复制代码
82. 无刷新切换li标签并且同时加载框架页面- var jq = jQuery.noConflict();
- jq(function(){
- jq("#changemenu>li").mouseover(function(){
- jq("#changemenu>li").each(function(i){
- jq(this).removeClass("current");
- });
- jq(this).addClass("current");
- document.getElementById("changenr").innerHTML='';
- }).mouseout(function(){
- jq(this).addClass("current");
- });
- });
复制代码
83. 快速发帖发布新话题- if (submitcheck('topicsubmit')) {
- $subject = $_POST['subject'];
- $message = $_POST['message'];
- $fid = $_GET['fid'];
-
- $tid = C::t('forum_thread')->insert_thread(array(
- 'fid' => $fid,
- 'subject' => $subject,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'dateline' => TIMESTAMP,
- ));
-
- C::t('forum_post')->insert_post(array(
- 'tid' => $tid,
- 'fid' => $fid,
- 'author' => $_G['username'],
- 'authorid' => $_G['uid'],
- 'message' => $message,
- 'dateline' => TIMESTAMP,
- ));
-
- showmessage('发帖成功', "forum.php?mod=viewthread&tid=$tid");
- }
复制代码
84. DISCUZ JSON数据解析获取- $str = 'a:2:{s:8:"sitename";s:8:"dz插件网";s:3:"pic";s:12:"ymg6.jpg";}';
- $newstr = str_replace("\", "", $str);
- $data = unserialize($newstr);
- echo $data['sitename']; // 输出结果为 dz插件网
复制代码
85. LI标签列表自适应宽度JS实现代码- <style>
- ul, li {margin: 0; padding: 0; list-style: none;}
- .list {width: 100%; margin: 0 auto;}
- .list li {width: 32%; float: left; margin-right: 2%; background: #0092B9; text-align: center; color: #fff; height: 300px; line-height: 300px; margin-bottom: 10px;}
- </style>
- <ul class="list">
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- <li>dz插件网</li>
- </ul>
- <script>
- $('.list li:nth-child(3n)').css('marginRight', '0');
- </script>
复制代码
86. 常用词汇
- select:选择
- count:总数
- table:表
- where:条件
- result:结果
- perpage:每页
- curpage:当前页
- update:更新
- delete:删除
- insert:写入
- dateline:日期
- time:时间
- echo:输出
- multi:分页函数
- if:如果
- else:否则
- elseif:否则如果
- start:起始
- limit:限制
- DESC:倒序
- ASC:正序
87. 活动帖发布页面核心处理文件- // source/class/extend/extend_thread_activity.php
复制代码
88. 分类信息解析文件- // source/function/function_threadsort.php
复制代码
89. 模板中运行PHP代码- <!--{eval echo 'dz插件网';}-->
复制代码
90. 标签获得焦点后触发- <input type="text" onfocus="ymgcom()" />
复制代码
91. 标签失去焦点后触发- <input type="text" onblur="ymgcom()" />
复制代码
92. 密码输出
```php
$password = preg_replace("/^
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。 |