<?php
$pageSize= 10; //每页显示的记录数
$hostname = "192.168.0.2"; //MSSQL Server
$dbuser = "sa"; //用户名
$dbpasswd = ""; //密码
//连接数据库
$conn = mssql_connect($hostname,$dbuser,$dbpasswd) or die("无法连接数据库服务器!");
//选择数据库
$db = mssql_select_db("unicom",$conn) or die("无法连接数据库!");
if(!intval($_REQUEST['page']))
{
$page = $_POST['page'];
}
else $page = $_REQUEST['page'];
if(empty($page)|| $page<1) $page = 1;
$maxpage = 10;
$current_page = $page;
if($conn->_connect())
{
if($_POST['content'])
$total_Record = $conn-> _get_Field("select count(*) from info_received WHERE src_phone LIKE '%".$_POST['content']."%'",0);
else
$total_Record = $conn-> _get_Field("SELECT COUNT(*) FROM info_received where time>convert(varchar(15),getdate()-day(30),112 )and time0)
$total_pages = intval($total_Record/$maxpage)+1;
else $total_pages = intval($total_Record/$maxpage);
if($_POST['content'])
$sql ="SELECT * FROM (select * from info_received where src_phone LIKE '%".str_replace("\\\\","\\",$_POST['content'])."%' AND rownum<'".(($current_page-1)*$maxpage+$maxpage)."' minus select * from info_received WHERE src_phone Like '%".str_replace("\\\\","\\",$_POST['content'])."%' and rownum<'".(($current_page-1)*$maxpage)."')";
else
$sql ="select * from (SELECT * FROM (select * from (select * from info_recdived where (time between (sysdate-90) and sysdate) order by time desc)) where rownum<'".(($current_page-1)*$maxpage+$maxpage)."' minus (select * from (select * from info_received WHERE (time between (sysdate-90) and sysdate) order by time desc) where rownum<'".(($current_page-1)*$maxpage)."')) order by time desc";
// write_log( "TES:".$sql );
$pd-> _executeQuery( $sql );
if($_POST['content1'])
$sql ="SELECT * FROM (select * from info_received where name LIKE '%".str_replace("\\\\","\\",$_POST['content'])."%' AND rownum<'".(($current_page-1)*$maxpage+$maxpage)."' minus select * from info_received WHERE name Like '%".str_replace("\\\\","\\",$_POST['content'])."%' and rownum<'".(($current_page-1)*$maxpage)."')";
else
$sql ="select * from (SELECT * FROM (select * from (select * from TB_VOICEMSG where (CREATETIIME between (sysdate-90) and sysdate) order by CREATETIIME desc)) where rownum<'".(($current_page-1)*$maxpage+$maxpage)."' minus (select * from (select * from TB_VOICEMSG WHERE (CREATETIIME between (sysdate-90) and sysdate) order by CREATETIIME desc) where rownum<'".(($current_page-1)*$maxpage)."')) order by CREATETIIME desc";
$pd-> _executeQuery( $sql );
$i = 0;
while($rs = @mssql_fetch_array( $pd->_get_R_handle(), mssql_BOTH ))
{ if($i++>10) break;
//echo "";
}
}
?>