<?php
session_start();

header("Cache-control: private"); 

include "../functions.php";
checkAdmin(session_id());

$title = "News Listing";

include "header.php";


	include "../conn.php";
	
	$query = "select date, subject, highlight, id from news order by date desc, id desc";
	
	$result = mysql_query($query);
	
//	echo '<form action="chghighlight.php method="post">';
	echo "<table border=0 bordercolor=black width=80% cellspacing=1 cellpadding=10>";
	
	while ($row = mysql_fetch_array($result))
	{
		if ($lastColor == 1) {
		$lastColor = 0;
		} else {
		$lastColor = 1;
		}
		altBG($lastColor);
		?>
		
		  <td width=15%>
		  <?php 
		  $year = substr($row[0], 0, 4);
		  $month = substr($row[0], 4, 2);
		  $day = substr($row[0], 6, 2);
		
 		  $date = "$day/$month/$year";
		  echo $date;
		  ?>
		  </td>
		  
		  <td width=70%>
		  <?php 
		  echo "$row[1]";
		  ?>
		  </td>
		  
		  <!--
		  <td>
		  <?php 
		  if ($row[2] == 1)
		  {
		  	echo '<input type="checkbox" name="highlight" checked>';
		  }
		  else
		  {
		  	echo '<input type="checkbox" name="highlight">';
		  }
		  ?>
		  </td>
		  -->
		  <td width=7%>
		  <?php
		  echo "<a href=edit.php?id=$row[3]>Edit</a>";
		  ?>
		  </td>
		  <td  width=8%>
		  <?php
		  echo "<a href=delete_handler.php?id=$row[3]>Delete</a>";
		  ?>
		  </td>
		</tr>
		
		<?php
		
	}
	?>
	<tr>
	<td colspan=4 align="right">
	</td>
	</tr>
	</table>
	</form>

<?php
include "footer.php";
?>