<?php 
include("h3.php");
    date_default_timezone_set('Asia/Bangkok');
	$date = date("Y/m/d");
	$date2 = date("d/m/Y");
?>
<center>
<br>
<?php
if($emp_name<>""&&$error<>1){
?>
<H2>รายการข่าวหลักหน้าแรกเว็บไซต์</H2>
<table width=90% class=Round3>
<tr>
	<td align=center>ลำดับ</td><TD align=center>หัวข้อข่าว</TD><TD align=center>date</TD><TD align=center>status</TD>
</tr>
<?php

if(!isset($_GET['flag_show']))
{
	$flag_show=0;
}else{
	
	$flag_show=$_GET['flag_show'];
}

//$flag_show=$_GET['flag_show'];
//	$NewsID=$_GET['NewsID'];
	//echo $NewsID;

if($flag_show==1&&$flag_show<>""){
	$NewsID=$_GET['NewsID'];
	echo $NewsID;
		$sql_dwc="update news_master  SET  active_status='$flag_show'  where  news_id = $NewsID"; 
		$dbquery = mysqli_query($con, $sql_dwc);

}else  if($flag_show==0&&$flag_show<>""){
		$NewsID=$_GET['NewsID'];
			echo $NewsID;

		$sql_dwc="update news_master  SET  active_status='$flag_show'  where  news_id = $NewsID"; 
		$dbquery = mysqli_query($con, $sql_dwc);
}
?>
<?php
$sql="SELECT * FROM news_master";
$result = mysqli_query($con, $sql); 
$t=1;
while($row = mysqli_fetch_array($result)) { 
		$NewsID=$row["news_id"];
		$Title=$row["title"];
		$Detail=$row["detail"];
		$Auther=$row["auther"];
		$AC_Status=$row["active_status"];
		if($AC_Status) {
			$showtext="Show";
			$color="00FF00";
			}
		else {
			$showtext="Hidden";
			$color="FF0000";
		   }
		$LikeNum=$row["like_count"];
		$NewsDate=$row["news_post_date"];
?>
<tr>
	<td><?php echo "$t";?></TD>
	<td>
	<?php 
	echo "<a href=\"pre_add_media.php?NewsID=$NewsID&flagadd=0&flag_delete=0\">$Title</a>";
	?></TD>
	<td><?php echo "$NewsDate"?></TD>
	<td>
	   <?php 
					if($AC_Status)
						echo "<font size=\"4\" color=\"#33ff00\"><strong><a href=\"list_post_news.php?flag_show=0&NewsID=$NewsID\">$showtext</strong></a></font>";
					else
						echo "<font size=\"4\" color=\"#ff3300\"><strong><a href=\"list_post_news.php?flag_show=1&NewsID=$NewsID\">$showtext</a></strong></font>";
	   ?>
	
	</TD>
</TR>
<?php
		$t++;
}

?>
</table>
<?php
		echo "<br><a href=\"frm_post_news.php\">Back to add new Post</a><br>";
?>
<HR width=90%></center>

<BR>
<?php
}
else{
      echo  "<CENTER>คุณไม่ผ่านการ Login /คุณคือไม่ได้รับสิทธิ์ในการใช้งาน?...</CENTER>";
      echo  "<CENTER><a href=\"index.php\">กลับสู่หน้า Login  อีกครั้ง</a></CENTER>";
}
?>

</center>
<?php 
include("button.php");
?>
