<title>Admin-Edit Videos</title>
<?php include("headertop.php"); 
include("config.php");
?>
<P><table width=100% bgcolor=white>
<tr><td width=50%><b>Name</td><td width=25%><b># Videos</td>
<td width=22%><b>Date Created</td><td width=3%><b>Delete</td>
<?php
mysql_connect($dbloc, $dbuser, $dbpass);
mysql_select_db($db); 
if(@$_POST['newcategory']){
$cat=@$_POST['newcategory'];
//Create Category
$date=date("F j, Y, g:i a");
$userdbname='categories';
$result = mysql_query("SHOW TABLE STATUS LIKE '$userdbname'");
$rowbb = mysql_fetch_array($result);
$categories = 'categories'. $rowbb['Auto_increment'];  
mysql_query("INSERT INTO categories(name, videos, date, ctn) VALUES('$cat', '0', '$date', '$categories')"); 
mysql_query("CREATE TABLE $categories( id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), userid VARCHAR(200), vname VARCHAR(200), description VARCHAR(300), date VARCHAR(100), privacy VARCHAR(100), fname VARCHAR(200), downloads VARCHAR(100), likes VARCHAR(100), image CHAR(50), duration CHAR(50), nextid CHAR(50))"); 
echo '<center>Category Created';
}
//Delete Category
if(@$_POST['delete']){
$duser=$_POST['delete'];
$dname=$_POST['dname'];
$results = mysql_query("DELETE FROM categories WHERE id='$duser'");
mysql_query("DROP TABLE $dname"); 
echo '<centeR>The Category was was deleted.';
}
$result = mysql_query("SELECT * FROM categories"); 
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
////////////////
echo '<tr><td width=50%>'. $row['name']. '</td><td width=25%>'. $row['videos']. 
'</td><td width=22%>'. $row['date']. '</td><td width=3%>'. '</td><td align=left>
<form action="admincategories.php" METHOD="post">
<input type=hidden name=delete value="'. $row['id']. ' ">
<input type=hidden name=dname value="'. $row['name']. ' ">
<input type=submit value="Delete"></form>
</td>';
}
?>
</table><P><table border=0 cellpadding=0 cellspacing=0 align=center width=85%>
<td><center><b>Create New Category</b><bR>
<form action="admincategories.php" METHOD="post">
<b>Name:</b><input type=text name=newcategory>
<input type=submit value="Create">
</form></td></table>
<?php include("headerbottom.php"); ?>
