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);
//計算留言數
$serial=$_GET["serial"];
if($_GET["SubjectID"]!=NULL) $SubjectID=$_GET["SubjectID"];
if($_POST["SubjectID"]!=NULL) $SubjectID=$_POST["SubjectID"];
if($_GET["CategoryID"]!=NULL) $CategoryID=$_GET["CategoryID"];
if($_POST["CategoryID"]!=NULL) $CategoryID=$_POST["CategoryID"];
if($_GET["county1ID"]!=NULL) $countyID=$_GET["county1ID"];
if($_POST["county1ID"]!=NULL) $countyID=$_POST["county1ID"];
if($_GET["mail_post1"]!=NULL) $mail_post1=$_GET["mail_post1"];
if($_POST["mail_post1"]!=NULL) $mail_post1=$_POST["mail_post1"];
$year=$_POST["year"];
$month=$_POST["month"];
if ( ($SubjectID or $CategoryID or $countyID or $mail_post1 or $year or $month)==NULL)
{
echo "請回上一頁輸入查詢條件,謝謝您。";
die;
}
$sql_cmd="SELECT serial,Day,title,count,CategoryID,SubjectID ,PubDay FROM data WHERE 1";
$sql_cmd2="SELECT count(*) FROM data WHERE 1";
echo $msg="
查詢條件:";
if($SubjectID!=0)
{
$sql_cmd = $sql_cmd." AND `SubjectID` LIKE '%$SubjectID%'";
$sql_cmd2 = $sql_cmd2." AND `SubjectID` LIKE '%$SubjectID%'";
$str = "select serial,Day,title,count,CategoryID,SubjectID,PubDay from $NEWS_TBL WHERE SubjectID = $SubjectID";
$str1="select subject.Description from subject where subject.SubjectID='$SubjectID'";
$list1=mysql_query($str1,$link);
list($Subject) = mysql_fetch_row($list1);
echo "$Subject ";
}
if($CategoryID!=0)
{
$sql_cmd = $sql_cmd." AND `CategoryID` LIKE '%$CategoryID%'";
$sql_cmd2 = $sql_cmd2." AND `CategoryID` LIKE '%$CategoryID%'";
$str = "select serial,Day,title,count,CategoryID,SubjectID,PubDay from $NEWS_TBL WHERE CategoryID=$categoryID";
$str1="select category.Description from category where category.CategoryID='$CategoryID'";
$list1=mysql_query($str1,$link);
list($Category) = mysql_fetch_row($list1);
echo "$Category ";
}
$str99="select county.Description from county where county.CountyID = '$mail_post1'";
$list99=mysql_query($str99,$link);
list($County) = mysql_fetch_row($list99);
echo "$County ";
if($mail_post1!=0)
{
$str11="select district.Description,CountyID from district where district.DistrictID='$mail_post1'";
$list1=mysql_query($str11,$link);
list($district,$county1ID) = mysql_fetch_row($list1);
$str12="select county.Description from county where county.CountyID='$county1ID'";
$list12=mysql_query($str12,$link);
list($county1) = mysql_fetch_row($list12);
echo "$county1 ";
echo "$district ";
}
$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%' ";
echo "$year";
echo "年";
}
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%'";
echo "$month";
echo "月";
}
$sql_cmd = $sql_cmd."order by Day desc";
$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 ";
}
?>
資料查詢系統 多重條件查詢
共有 筆資料
發佈時間
時間
標題
類別
主題
人氣值
while(list($serial,$Day,$title,$count,$categoryID,$subjectID,$PubDay) = mysql_fetch_row($list)){
if(strlen($title)>80){
$title=substr($title,0,80)."-----";
}
$str1="select category.Description from category where category.CategoryID='$categoryID'";
$list1=mysql_query($str1,$link);
list($category) = mysql_fetch_row($list1);
echo "