<?
header("Cache-Control: no-cache, must-revalidate");
header("Content-type: application/xml; charset=UTF-8");

include_once ("session.php");
include_once ("dbcon_light.php");

$tbname = "notice_demo";
if ($ipp=="") $ipp = 7;
if ($ten=="") $ten = 5;
if ($page == "" || $page<=0) $page = 1;
$startrow = ($page - 1) * $ipp;
$startpage = (ceil($page/$ten)-1)*$ten + 1;
if ($startpage <= 0) $startpage = 1;
if ($page <= 0) $page = 1;
$startpage_ten = $startpage - $ten;
if ($startpage_ten <= 0) $startpage_ten = 1;

$where_add = " 0=0 ";	

if ($keyword!="")
	$where_add .= " and $keyfield like '%$keyword%' ";

$sqltot = "select count(*) as tot from $tbname where ".$where_add;
$rst = mysql_select_list($sqltot);
$totrec = $rst[tot][0];
			
$totpage = ceil($totrec / $ipp);
$endpage = $startpage + $ten -1;
if ($endpage > $totpage)
	$endpage = $totpage;

$sql = "select * from $tbname where $where_add ";
$sql .= " order by rowid desc limit $startrow, $ipp";
$rs = mysql_select_list($sql);

?>
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?".">"; ?>
<lists>
	<info>
		<page><? echo $page;?></page>
		<totpage><? echo $totpage;?></totpage>
		<startpage><? echo $startpage;?></startpage>
		<endpage><? echo $endpage;?></endpage>
		<totrec><? echo $totrec;?></totrec>
		<ipp><? echo $ipp;?></ipp>
		<ten><? echo $ten;?></ten>
		<sqltot><![CDATA[<? echo $sqltot;?>]]></sqltot>
		<sql><![CDATA[<? echo $sql;?>]]></sql>
		<count><? echo count($rs[rowid]);?></count>
	</info>
	<? for ($i=0;$i<count($rs[rowid]);$i++) { ?>  
	<data>
		<rowid><? echo $rs[rowid][$i];?></rowid>
		<subject><![CDATA[<? echo $rs[subject][$i];?>]]></subject>
		<reg_date><![CDATA[<? echo $rs[reg_date][$i];?>]]></reg_date>
		<content><![CDATA[<? echo $rs[content][$i];?>]]></content>
	</data>
	<? }// for i?>
</lists>