<?php
session_start();

if ($_SESSION["denglu"] != 1)
{
	echo "<h3>you have not logged in</h3>";
	echo "If you are an administrator, <a href=../login.php>login here</a><br>";
	echo "If you are not administrator, <a href=../index.htm>visit our website</a>";
	exit;
}

include "header.php";

function altBG($lastColor) {
	if ($lastColor == 1) {
	echo "<tr bgcolor=\"#C9C9C9\">";
	} elseif ($lastColor == 0) {
	echo "<tr bgcolor=\"#E9E9E9\">";
	}
}

//display all the category
$link = mysql_connect("localhost", "whateversg", "what0820");
mysql_select_db("whatever_com_sg", $link);
?>



<center>

<table width="80%" border="0" cellpadding=5 cellspacing=1>
<th><b>Category name</b></th>
<th><b>Category Description</b></th>
<th colspan="2"><b>Options</b></th>

<?php
$query = "select * from media_category";

$result = mysql_query($query);

while ($row = mysql_fetch_array($result))
{
	if ($lastColor == 1) 
	{
		$lastColor = 0;
	} 
	else 
	{
		$lastColor = 1;
	}

	altBG($lastColor);

	$id = $row[0];
	$name = $row[1];
	$descrip = $row[2];
	
	echo "<td align=\"left\" valign=\"top\">$name</td>";
	echo "<td align=\"left\" valign=\"top\">$descrip</td>";
	echo "<td align=\"left\" valign=\"top\"><form action=\"modCategory.php\" method=\"post\"><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"submit\" value=\"Modify\"></form></td>";
	echo "<td align=\"left\" valign=\"top\"><form action=\"delCategory.php\" method=\"post\"><input type=\"hidden\" name=\"id\" value=\"$id\"><input type=\"submit\" value=\"Delete\"></form></td>";
	echo "</tr>";
}
?>

</table>

</center>

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