<?php

include("config/connect.php");
include("functions.php");

$aucid=$_GET["aucid_new"];
$uid = $_SESSION["userid"];

$qryhis1 = "select * from chat c left join registration r on c.user_id=r.id where c.bid='$aucid'  order by addtime desc limit 0,10";
$reshis1 = mysql_query($qryhis1) or die(mysql_error());
$total1  = mysql_num_rows($reshis1);
while($obj= mysql_fetch_object($reshis1)) {
	$chat_list[] = $obj;
}
for($i = 1;$i <= $total1;$i++) {
	$obj = $chat_list[$total1 - $i];
	if($i == 1) {
		$temp = '{"chatrec":{"username":"kxx'.$obj->username.'","content":"'.urlencode($obj->content).'","addtime":"'.date('Y-m-d H:i:s',$obj->addtime).'"}}';
	} else {
		$temp .= ',{"chatrec":{"username":"'.urlencode($obj->username).'","content":"'.urlencode($obj->content).'","addtime":"'.date('Y-m-d H:i:s',$obj->addtime).'"}}';
	}
}

echo iconv('gb2312','utf-8',"[".$temp."]");

?>