<?php
header("Content-Type:text/html;charset=GB2312");

include("conn.php");

 $num = $_POST['num']+1;
 //if($num = 0) $num = $num +1;

 $query = "select a.id,a.title,a.pic,a.hits,a.classid,b.catedir,b.catename from content a left join category b on a.classid=b.cateid where a.islock=1 and a.ispic=1 order by a.id desc";
 $rs->open($query,$conn,1,3);
 $pagesize=$rs->Pagesize=10;

if($num<=$rs->PageCount){
	
 	if($rs->PageCount<>0){
	 	if(!empty($num)){
			if($num<=0){
				$rs->AbsolutePage=1;
				$nowpage=1;
			}elseif($num>$rs->PageCount){
				$rs->AbsolutePage=$rs->PageCount;
				$nowpage=$rs->PageCount;
			}else{
				$rs->AbsolutePage=$num;
				$nowpage=$num;
			}
		}else{
			$rs->AbsolutePage=1;
			$nowpage=1;
		}
	 }else{
	 	$nowpage = 1;
		$pagesize = 0;
	 }
 
 	$temp_arr = array();
	
 	for($i=1;$i<=$pagesize;$i++){
	 	if (!$rs->EOF){
			$url = "http://www.uncletoo.com/html/".$rs->fields['catedir']."/".$rs->fields['id'].".html";
			$ary =array("title"=>urlencode((string)$rs->fields['title']),"image"=>"http://www.uncletoo.com".(string)$rs->fields['pic'],"id"=>(string)$rs->fields['id'],"classid"=>(string)$rs->fields['classid'],"url"=>$url,"hits"=>(string)$rs->fields['hits'],"catename"=>urlencode((string)$rs->fields['catename']));
			
			$temp_arr[] = $ary;
			$rs->movenext;
		}
	 }
	 
$json_arr = array();
 foreach($temp_arr as $k=>$v){
     $json_arr[]  = (object)$v;
 }
 //echo($temp_arr[1]);
 echo urldecode(json_encode($json_arr));

}

?>
