*/ include_once("./wp-config.php"); $type=intval($_GET["type"]); if ($type == 2) { $type = 2; $linkName = "local-news"; } else if ($type == 9) { $type = 9; $linkName = "announcement"; } else { $type = 1; $linkName = "news"; } $connection = @mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); mysqli_set_charset($connection, "utf8"); $extraLink = ""; $stDate = $_GET["stDate"]; $edDate = $_GET["edDate"]; if (!ckDateOnly($stDate)) {$stDate = "";} if (!ckDateOnly($edDate)) {$edDate = "";} if ($stDate != "" && $edDate != "") { $extraLink .= " AND post_date >= '$stDate' AND post_date <= '$edDate' "; } else if ($stDate != "") { $extraLink .= " AND post_date >= '$stDate' "; } else if ($edDate != "") { $extraLink .= " AND post_date <= '$edDate' "; } $searchQ = $_GET["searchQ"]; $searchQ = str_replace("'","",$searchQ); $searchQ = str_replace("\\","",$searchQ); $searchQ = str_replace('"',"",$searchQ); if ($searchQ != "") { $searchQT = mysqli_real_escape_string($connection,$searchQ); $extraLink .= " AND post_title like '%$searchQT%' "; } $sql = "SELECT count(*) as total FROM wp_posts AS a LEFT JOIN wp_term_relationships AS b ON a.ID = b.object_id WHERE b.term_taxonomy_id = '$type' AND a.post_status='publish' AND post_type='post' $extraLink "; $qy = mysqli_query($connection,$sql); $result = array(); if($qy){ while ($row = $qy->fetch_object()){ array_push($result,$row); } } $data_nums = $result[0]->total; mysqli_free_result($qy); $per = 10; $pages = ceil($data_nums/$per); if (!isset($_GET["page"])){ //假如$_GET["page"]未設置 $page=1; //則在此設定起始頁數 } else { $page = intval($_GET["page"]); //確認頁數只能夠是數值資料 } $start = ($page-1)*$per; $sql = "SELECT a.post_date,a.post_title,a.ID FROM wp_posts AS a LEFT JOIN wp_term_relationships AS b ON a.ID = b.object_id WHERE b.term_taxonomy_id = '$type' AND a.post_status='publish' AND post_type='post' $extraLink ORDER BY a.post_date DESC LIMIT $start,$per "; $qy = mysqli_query($connection, $sql); $result = array(); if($qy){ while ($row = $qy->fetch_object()){ array_push($result,$row); } } mysqli_free_result($qy); echo '
'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'; echo '
'; if (sizeof($result) == 0) { echo '查無資料'; } else { echo ''; for ($i=0;$i'; if ($i==0) {$code = 'style="width:120"';} else {$code='';} echo ''; echo ''; echo ''; } echo '
'.substr($result[$i]->post_date,0,10).''.$result[$i]->post_title.'
'; } if (intval($_GET["page"]) == 0) { $_GET["page"] = 1; } if ($pages >= 2) { $link = "./local-news.php?type=$type&stDate=$stDate&edDate=$edDate&searchQ=$searchQ"; echo '
'; echo ''; echo '
'; } function linkMake($title) { $title = str_replace(" ","-",$title); $title = str_replace(".","-",$title); return $title; } function ckDateOnly($datetime) { $datetime = str_replace('-', ' ', $datetime); $datetime = str_replace('/', ' ', $datetime); $datetime = str_replace(':', ' ', $datetime); $array = explode(' ', $datetime); $aa = explode(' ', $datetime); $array=array(); for($i=0;$i