<?php
session_start();
if ($_SESSION['login']!="ok") {
	echo "<script language='javascript'>";
	echo " location='./';";
	echo "</script>";
}
?>
<?php
require("config.php");
require("conn.php");
require("function.php");
$line=50;
$limit=$_POST['limit'];
$start=$_POST['start'];
$time=$_POST['time'];
$kind=$_POST['kind'];
if($kind==13){$kind="";}
if($time!=""){
	if($kind!=""){		
		$count=@mysql_query("select count(id) as count from star_content  where kind='$kind' and time='$time'",$db);
	}else{
		$count=@mysql_query("select count(id) as count from star_content  where time='$time'",$db);
	}
	
}else{
	if($kind!=""){		
		$count=@mysql_query("select count(id) as count from star_content  where kind='$kind'",$db);
	}else{
	    $count=@mysql_query("select count(id) as count from star_content ",$db);
	}
}

$count_nu=@mysql_fetch_array($count);
$count_number=$count_nu['count'];
$i=0;
echo "{total:$count_number,results:[";
if($start+$limit>$count_number){//这里对传过来的limit做了处理,以免超出数据库总记录的范围
	$limit=$limit-($start+$limit-$count_number);
}
if($title!=""){
	if($kind!=""){
		$req=@mysql_query("select * from star_content  where kind='$kind' and time='$time' order by id DESC limit $start,$limit",$db);
	}else{
		$req=@mysql_query("select * from star_content  where time='$time' order by id DESC limit $start,$limit",$db);
	}
	
}else{
	if($kind!=""){
		$req=@mysql_query("select * from star_content  where kind='$kind'  order by id DESC limit $start,$limit",$db);
	}else{
		$req=@mysql_query("select * from star_content   order by id DESC limit $start,$limit",$db);
	}
	
}
while($return=@mysql_fetch_array($req)){
    $a=$return['id'];
	$b=$return['value'];
	$c=$return['starshow'];	
	$d=$return['time'];		
	$e=$return['kind'];		
	echo "{
                    id: $a,
                    value: '$c',
                    starshow: '$b',
					time:'$d',
					kind:'$e'					
                }";
				$i++;
	if($i<$limit){echo ",";}				
	
	}
	echo "]}";
?>
