<?php

include '../library/category_header.php';

?> 
<?php if ($rowxxx[HELPBOX] == $nil || $rowxxx[HELPBOX] == Show) { ?>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Tool Tips</b></td>
</tr>
<tr> 
<td class="td4" valign="top"> 
<p><img src="../images/Help.png" width="64" height="64"></p>
</td>
<td class="td4" width="100%" valign="top"> 
<table width="100%" align="center" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td> 
<div align="center"><i><img src="../images/add-folder-yellow.gif" width="14" height="14" /></i></div>
</td>
<td class="font1" width="100%"> Edit sub-level categories.</td>
</tr>
<tr> 
<td> 
<div align="center"><img src="../images/delete-page-red.gif" width="14" height="14" /></div>
</td>
<td class="font1" width="100%"> Delete this category.</td>
</tr>
<tr> 
<td> 
<div align="center"><img src="../images/edit_listing.jpg" width="22" height="22" /></div>
</td>
<td class="font1" width="100%"> Edit this category.</td>
</tr>
</table>
</td>
</tr>
</table>
<br>
<?PHP } ?>
<form action="../library/query.php" method="post" name="form" id="form">
<?php
  
$SQL = "SELECT * from CATEGORIES WHERE ID = '$_GET[id]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
if (empty($_GET[qt])) $qt = insert; else $qt = update;

?>
<input type="hidden" name="controller" value="<?php echo "CATEGORIES~$qt~categories&catid=$_GET[catid]~$_GET[id]"; ?>" />
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Add / Edit Category 
<input type="hidden" name="CATEGORY" value="<?php echo $_GET[catid]; ?>" />
</b> </td>
</tr>
<tr> 
<td class="td4"  width="50%"> Category Name</td>
<td class="td4"  width="50%"> 
<input type="text" name="TITLE" value="<?php echo $row[TITLE]; ?>" class="textarea100" />
</td>
</tr>
<tr> 
<td class="td4"  width="50%"> Category Icon (upload images to the category_icons directory)</td>
<td class="td4"  width="50%"> 
<select name="CATICON">
<option selected> 
<?php echo $row[CATICON]; ?>
</option>
<option value=""></option>
<?PHP
$filearray = array(); if ($fil = @opendir("../category_icons/")) {
while (($file = readdir($fil)) !== false) {
if ($file != "." && $file != "..") { $filearray[] = $file;
?>
<option> 
<?php echo $file; ?>
</option>
<?PHP }}closedir($fil);} ?>
</select>
</td>
</tr>
<tr> 
<td class="td4">&nbsp; </td>
<td class="td4"> 
<input type="submit" name="Submit" value="Submit">
</td>
</tr>
</table>
<br>
<table width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="2"> <b> Category Browser</b> </td>
</tr>
<tr> 
<td class="td4" colspan="2"> 
<?php

//---------------------->

$SQL = "SELECT * from CATEGORIES WHERE ID = '$_GET[id]'"; $result = @mysql_query( $SQL ); $row = @mysql_fetch_array( $result );
$title = $row[TITLE];
$id = $row[ID];
if (empty($_GET[qt]))$qt = insert;
if ($_GET[qt] == update) $qt = update;

//---------------------->

?>
<?php

//---------------------->

category_header($_GET[catid],"categories",categories,catid,$rowxxx[MR]);

//---------------------->

 ?>
</td>
</tr>
</table>
<br />
<table  width="100%" cellpadding="0" cellspacing="0" border="0">
<tr> 
<td class="td3" colspan="4"> <b> Categories</b> </td>
</tr>
<?php

$SQL = "SELECT * from CATEGORIES WHERE CATEGORY = '$_GET[catid]' ORDER BY TITLE ASC"; $result = @mysql_query( $SQL );
while( $row = @mysql_fetch_array( $result ) ) {
?>
<tr> 
<?PHP
$sql2 = "SELECT count(*) FROM CATEGORIES WHERE CATEGORY = '$row[ID]'";
$res2 = @mysql_query($sql2); $row2 = @mysql_fetch_row($res2);
?>
<td class="td4"> <a href="?page=categories&catid=<?php echo $_GET[catid]; ?>&qt=update&id=<?php echo $row[ID]; ?>"><img src="../images/edit_listing.jpg" border="0"></a> </td>
<td class="td4" width=100%><a href="?page=categories&catid=<?php echo $row[ID]; ?>"> 
<?php echo $row[TITLE]; ?>
</a> 
<?php echo "($row2[0])"; ?>
</td>
<td class="td4"> <a href="?page=categories&catid=<?php echo $row[ID]; ?>"> <img src="../images/add-folder-yellow.gif" border="0"></a> </td>
<td class="td4"> <a href="../library/delete.php?id=<?php echo $row[ID]; ?>&return=categories&catid=<?php echo $_GET[catid]; ?>&category=<?php echo $row[ID]; ?>&type=CATEGORIES&catdel=1"> <img src=../images/delete-page-red.gif delete-page-red.gif border=0></a></td>
<?PHP } if ($row2[0] == "") { ?>
<tr> 
<td colspan="4" class="td4">No categories found.</td>
</tr>
<?PHP } ?>
</table>
</form>
