<?php
session_start();
include "../functions.php";

$sessionID = session_id();

checkAdmin($sessionID);

?>

<?php
$title = "News Categories";
include "header.php";
?>
<tr>
<td width=100%>
  <table border=0 width=100% cellpadding=5>
  <tr bgcolor="#a0a0a0"><th>Name</th><th>Description</th><th colspan=2>Options</th></tr>
    <?php
    $query = "select * from news_category order by categoryName asc";
    $result = mysql_query($query) or die (mysql_error());
    
    $trigger = 1;
    
    while ($row = mysql_fetch_array($result))
    {
    	$categoryID = $row[0];
    	$categoryName = $row[1];
    	$categoryDescrip = $row[2];
    	
    	$trigger = ($trigger + 1) % 2;
    	
    	if ($trigger)
    	{
    		echo "<tr bgcolor=\"#c9c9c9\">";
    	}
    	else
    	{
    		echo "<tr bgcolor=\"#e9e9e9\">";
    	}
    	?>
    	
    	  <td><?php echo $categoryName; ?></td>
    	  <td><?php echo $categoryDescrip; ?></td>
    	  <td align="right"><form action="modCategory.php" method="post"><input type="hidden" name="categoryID" value="<?php echo $categoryID; ?>"><input type="submit" value="Modify"></td></form>
    	  <td align="left"><form action="delCategory.php" method="post"><input type="hidden" name="categoryID" value="<?php echo $categoryID; ?>"><input type="submit" value="Delete"></td></form>
    	</tr>
    	<?php
    }
    ?>
  </table>
</td>
</tr>
<?php
include "footer.php";
?>