require "include/setup.php";
$link=mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$link);
mysql_query("SET NAMES utf8", $link);
//計算留言數
$page_num=$_GET["page_num"];
$SubjectID=$_POST["SubjectID"];
$CategoryID=$_POST["CategoryID"];
$year=$_POST["year"];
$month=$_POST["month"];
$mail_post1=$_POST["mail_post1"];
$county1ID=$_POST["county1ID"];
$serial=$_GET["serial"];
$SubjectID=$_GET["SubjectID"];
$CategoryID=$_GET["CategoryID"];
$mail_post1=$_GET["mail_post1"];
$county1ID=$_GET["county1ID"];
$sql_cmd="SELECT serial,Day,title,count,CategoryID,SubjectID ,PubDay FROM data WHERE 1";
$sql_cmd2="SELECT count(*) FROM data WHERE 1";
//$select=0;
if($CategoryID!=0)
{
$sql_cmd = $sql_cmd." AND `CategoryID` LIKE '%$CategoryID%'";
$sql_cmd2 = $sql_cmd2." AND `CategoryID` LIKE '%$CategoryID%'";
}
if($SubjectID!=0)
{
$sql_cmd = $sql_cmd." AND `SubjectID` LIKE '%$SubjectID%'";
$sql_cmd2 = $sql_cmd2." AND `SubjectID` LIKE '%$SubjectID%'";
}
$sql_cmd = $sql_cmd." AND (`CountyID` LIKE '%$mail_post1%' OR `DistrictID` LIKE '%$mail_post1%' )";
$sql_cmd2 = $sql_cmd2." AND (`CountyID` LIKE '%$mail_post1%' OR `DistrictID` LIKE '%$mail_post1%' )";
if($year!=0)
{
$sql_cmd = $sql_cmd." AND extract(year FROM Day) LIKE '%$year%' ";
$sql_cmd2 = $sql_cmd2." AND extract(year FROM Day) LIKE '%$year%' ";
}
if($month!=0)
{
$sql_cmd = $sql_cmd." AND extract(month FROM Day) LIKE '%$month%'";
$sql_cmd2 = $sql_cmd2." AND extract(month FROM Day) LIKE '%$month%'";
}
$sql_cmd = $sql_cmd."Order by Day desc";
//echo $sql_cmd2;
$str=$sql_cmd;
$list =mysql_query($str,$link);
$list2 =mysql_query($sql_cmd2,$link);
list($news_count) = mysql_fetch_row($list2);
function subject($subjectID)
{
require "include/setup.php";
$link=mysql_connect($DB_SERVER,$DB_USER,$DB_PASS);
mysql_select_db($DB_NAME,$link);
mysql_query("SET NAMES utf8", $link);
$str5="select subject.Description from subject where subject.SubjectID LIKE '%$subjectID%'";
$list5=mysql_query($str5,$link);
list($subject) = mysql_fetch_row($list5);
echo "$subject ";
}
?>
資料查詢系統