<?php

require_once "./include/common.inc.php";
require_once DEDE.'./../include/pub_datalist_dm.php';

$q = trim($q);

$query = "select id, tid, tidname, tid2, tid2name, uid, title, reward, dateline, status, replies from {$cfg_dbprefix}ask where title like '%$q%'";
$dlist = new DataList();
$dlist->pageSize = 20;

$dlist->SetParameter("q",$q);
$dlist->SetSource($query);

$dsql = new dedesql();

//会员排行
$query = "select ID, userid, scores from {$cfg_dbprefix}member order by scores desc limit 10";
$dsql->setquery($query);
$dsql->execute();
$topmembers = array();
while($row = $dsql->getarray())
{
	$topmembers[] = $row;
}

//快到期问题
$query = "select id, tid, tidname, tid2, tid2name, title from {$cfg_dbprefix}ask where status='0' order by expiredtime asc, dateline desc limit 10";
$dsql->setquery($query);
$dsql->execute();
$expiredasks = array();
while($row = $dsql->getarray())
{
	if(strlen($row['title']) > 24){
		$row['title'] = cn_substr($row['title'],24).'...';
	}
	$expiredasks[] = $row;
}
include DEDE.'./template/default/search.htm';
$dsql->Close();
?>