获得分类的相关文章


//获得相关文章,有两个参数,分别是文章分类和显示条数.如果参数没有写的话,默认分类为未分类,显示条数为6条

function getgxtext($fenlei,$shuliang){

$fl = isset($fenlei) ? $fenlei : -1;

$sl = isset($shuliang) ? $shuliang : 6;

$db = MySql::getInstance();

//获得所有子分类

$sql = "SELECT * FROM ".DB_PREFIX."sort WHERE pid = ".$fl;

$subsort = '';

$sql = $db->query($sql);

while($row = $db->fetch_array($sql)){

$subsort .= ' or sortid = '.$row['sid'];

}

//echo '子分类为:'.$subsort;

$sql = "SELECT * FROM ".DB_PREFIX."blog WHERE  hide='n' and checked='y' and (sortid = ".$fl.$subsort.") order by gid desc limit ".$sl."";

return $db->query($sql);

}

?>

你可能感兴趣的:(获得分类的相关文章)