个克米dz首页调用有段代码不明白
[php]<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: index.php 13764 2008-05-19 03:14:01Z heyond $
*/
define('CURSCRIPT', 'index');
require_once './include/common.inc.php';
require_once DISCUZ_ROOT.'./include/forum.func.php';
require_once DISCUZ_ROOT.'./include/misc.func.php';
$today = mktime (0,0,0,date("m") ,date("d"),date("Y"));
$build_date = mktime (0,0,0,06,10,2007);//里面的三个数字,分别代表你论坛运行第一天的月,日,年。
$build_days = (int)(($today-$build_date)/(24*3600));
//---设置---start
$shownums = 6;//演示个数 6以内
$searchnums = 18;//搜索总数.
$cachelife = 600;//缓存时间.
$orderby = 'rand';//搜索顺序:按日期dateline.按浏览次数downloads.随机rand.
$cachename = 'showpic';//缓存名.若与何插件冲突请修改,只要不冲突不会影响使用.
$searchfid = '';//搜索fid范围.不限制留空.请用逗号相隔,如'1,2,3'.
//---设置---end
if((@!include('forumdata/cache/cache_'.$cachename.'.php')) || $expiration < time() || $cacheshownums != $shownums || $cachesearchnums != $searchnums || $cachecachelife != $cachelife || $cacheorderby != $orderby || $cachecachename != $cachename || $cachesearchfid != $searchfid) {
require_once './include/common.inc.php';
$orderby = $orderby != 'rand' ? 'attach.'.$orderby : 'rand()';
$fids = $searchfid ? 'AND '."t.fid IN ($searchfid)" : '';
$data = array();
$query = $db->query("SELECT attach.aid, attach.attachment, t.tid, t.fid, t.subject FROM {$tablepre}attachments attach LEFT JOIN {$tablepre}threads t ON t.tid=attach.tid WHERE attach.readperm='0' AND displayorder>='0' AND filetype='image/pjpeg' $fids GROUP BY attach.tid ORDER BY $orderby DESC LIMIT $searchnums");
while ($pic = $db->fetch_array($query)) {
$data['pic'][$pic[aid]]['showpicpics'] = $attachurl.'/'.$pic['attachment'];
$data['pic'][$pic[aid]]['showpiclinks'] = "viewthread.php?tid=$pic[tid]";
$data['pic'][$pic[aid]]['showpictexts'] = str_replace('\'', ' ',$pic['subject']);
}
$data['expiration'] = $cachelife + time();
$data['cacheshownums'] = $shownums;
$data['cachesearchnums'] = $searchnums;
$data['cachecachelife'] = $cachelife;
$data['cacheorderby'] = $orderby;
$data['cachecachename'] = $cachename;
$data['cachesearchfid'] = $searchfid;
require_once DISCUZ_ROOT.'./include/cache.func.php';
writetocache($cachename, '', getcachevars($data));
include(DISCUZ_ROOT.'./forumdata/cache/cache_'.$cachename.'.php');
}
shuffle($pic);
$i = 0;
$j = 0;
while ($j < $shownums && isset($pic[$i])) {
if(is_readable($pic[$i]['showpicpics'])) {
$showpicpics .= $comma.$pic[$i]['showpicpics'];
$showpiclinks .= $comma.$pic[$i]['showpiclinks'];
$showpictexts .= $comma.$pic[$i]['showpictexts'];
$comma = '|';
$j++;
}
$i++;
}
$colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
//论坛导航
$statvars = array();
$query = $db->query("SELECT name, threads FROM {$tablepre}forums ORDER BY displayorder");
while($variable = $db->fetch_array($query)) {
$variable['name'] = strip_tags($variable['name']);
$statvars[$variable['name']] = $variable['threads'];
}
$threadshot1 = array();
if(isset($statvars['threads'])) {/*******************************这个if判断不明白是什么意思,我想直接用else后下面的数据不就可以了么.****************************/
$threadshot = array_slice(unserialize($statvars['threads']),0,10);
} else {
$statvars['forums'] = 0;
$query = $db->query("SELECT fid, name, threads FROM {$tablepre}forums WHERE status>0 AND type<>'group' ORDER BY displayorder");
while($forum = $db->fetch_array($query)) {
$threadshot1[] = $forum;
}
}
[/php]
本来是想问那个程序员的,可是没联系上,只有发到这里和大家一起看下了. 没人用过么? isset($statvars['threads'
检查是否有板块存在估计
不是很了解,帮你顶 [php]
$query = $db->query("SELECT name, threads FROM {$tablepre}forums ORDER BY displayorder");
while($variable = $db->fetch_array($query)) {
$variable['name'] = strip_tags($variable['name']);
$statvars[$variable['name']] = $variable['threads'];
}
$threadshot1 = array();
if(isset($statvars['threads']))
[/php]
但是sql里没'threads'这个字段 我是会调用,其他的我不会
回复 5# ahsxw 的帖子
[php]} else {
$statvars['forums'] = 0;
$query = $db->query("SELECT fid, name, threads FROM {$tablepre}forums WHERE status>0 AND type<>'group' ORDER BY displayorder");
while($forum = $db->fetch_array($query)) {
$threadshot1[] = $forum;
}
[/php]
这段代码就是调用的.不知道为什么要加个if(...............判断? 继续问 再顶一下,问问有人知道不? 今天再问
页:
[1]
