问答插件,所有的回答不能分页,哪位高手帮忙解决下
<?php
if ( !defined( "IN_UCHOME" ) )
{
exit( "Access Denied" );
}
$id = (int)$_GET['id'];
if (empty($id)) {
showmessage('参数错误', 'ask.php');
}
$ask_id = & $id;
//获取信息
$sql = "SELECT * FROM ".tname("app_ask")." WHERE id= $id ";
$query = $_SGLOBAL['db']->query( $sql );
$ask = $_SGLOBAL['db']->fetch_array( $query );
realname_set($ask['uid'],$ask['username']);
if (empty($ask)) {
showmessage("信息不存在或者已经被删除", 'ask.php?do=ask');
}
//更新点击数回复数
$ask_hfx = $_SGLOBAL['db']->result($_SGLOBAL['db']->query("SELECT COUNT(*) FROM ".tname('app_ask_reply')." WHERE ask_id = $ask_id"), 0);
$sql = "UPDATE ".tname("app_ask")." SET view_count = view_count + 1, reply_count =$ask_hfx WHERE id = ".$id;
$_SGLOBAL['db']->query( $sql );
//评论
$theurl = "ask.php?do=ask&ac=view&id={$ask_id}";
$reply = array();
$sql = "SELECT * FROM ".tname('app_ask_reply')." WHERE ask_id = $ask_id ORDER BY id ";
$query = $_SGLOBAL['db']->query($sql);
$count = 0;
$arr_ids = array();
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
realname_set($value['uid'],$value['username']);
$value['content'] = nl2br(htmlspecialchars($value['content'])) ;
$reply[] = $value;
$arr_ids[] = $value['id'];
$count++;
}
//取 hot
$filePath = S_ROOT."./data/ask_hot_cache.php";
//如果获取失败 或者 缓存内容为空 或者 缓存文件的修改时间 早于$expire_time前 ,就重构缓存
if ( file_exists($filePath) && (time() - filemtime($filePath)) < 60*3 )
{
$code = @file_get_contents($filePath); //获取缓存内容
$hotask = unserialize($code);
}
if (empty($hotask) ) {
$hotask = array();
$where = "WHERE status=1 ";
$sql = "SELECT * FROM ".tname("app_ask")." $where ORDER BY score DESC limit 10";
$query = $_SGLOBAL['db']->query( $sql );
while ( $value = $_SGLOBAL['db']->fetch_array( $query ) )
{
$hotask[] = $value ;
}
swritefile($filePath, serialize($hotask));
}
//$sql = "UPDATE ".tname("app_ask")." SET reply_count ={$count} WHERE id = ".$id;
//$_SGLOBAL['db']->query( $sql );
$str_ids = implode(",", $arr_ids);
//实名
realname_get();
include_once( template( "ask/view/ask_view" ) );
?> |