Location: PHPKode > scripts > ScreamingToDos > std-0.9/category.php
<?PHP
require "login.php";


$q = "SELECT id,category,open_sortby,closed_sortby,owner,closed_show,open_show,DATE_FORMAT(created_date, '%m.%d.%y') AS created_date,sort_number FROM $categorytable WHERE owner=\"$currentuser\" ORDER BY $category_sortby";
$categoryR = qDB($q);
$num_categories = mysql_num_rows($categoryR);

$currentPage = "STD->category";
$confirmStr = "Are you sure you want to delete this category and all its items?";
require "header.php";
?>
<center>
<?PHP if (!($num_categories)) { ?>
 <font face="<?PHP echo $pageFont ?>" size="+<?PHP echo ($pageFontsize+2) ?>" color="<?PHP echo $errorForeCol ?>">
<strong>Please create a category to start putting your tasks in:</strong>
 </font>
<?PHP } ?>
<?PHP if (!($print)) { ?>
<form method="post" action="category.php" name="addcategory">
 <table border=0 cellpadding=0 cellspacing=0 width="1">
  <tr vlign=center>
<?PHP
if ($multiuser) {
 echo "   </td><td align=left>";
 echo "   <font face=\"$pageFont\" size=\"".($pageFontsize+1)."\"><strong>Assigned:</strong></font>";
}
?>
   </td><td align=left>
    <font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize+1 ?>"><strong>Category name:</strong></font>
   </td>
  </tr>
  <tr valign=center>
<?PHP if ($multiuser) { ?>
   <td align=left width="1">
   <select name="owner" size="1">
<?PHP
 $r = qDB("SELECT username FROM $usertable ORDER BY username");
 while ($d = mysql_fetch_array($r)) {
  if ($d[0] == $currentuser) { $SEL = "SELECTED"; } else { $SEL = ""; }     
  echo "<option $SEL value=\"".$d[0]."\">".$d[0]."\n";
 }
 echo "   </select>\n";
}
?>
   <td align="left">
    <input type="text" size="60" maxlength="200" name="category">
   </td>
  </tr>
  <tr>
   <td colspan=5 align="right">
    <input type="hidden" name="addcat" value="1">
<?PHP if (!($multiuser)) { ?>
    <input type="hidden" name="owner" value="<?PHP echo $currentuser ?>">
<?PHP } ?>
    <input type="submit" value="+ add +">
   </td>
  </tr>
 </table>
</form>
<?PHP if (!($editcat)) { ?>
<script>
 document.addcategory.category.focus();
</script>
<?PHP } ?>
</center>
<?PHP }
if ($num_categories) {
?>
<form method="post" action="category.php" name="editcategory">
<table width="90%" border="0" align="center">
 <tr>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><?PHP if (!($print)) { ?><a href="category.php?updatecatsort=sort_number"><?PHP } ?>Sort order</a></font></strong></td>

  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><?PHP if (!($print)) { ?><a href="category.php?updatecatsort=created_date"><?PHP } ?>Date added</a></font></strong></td>

<?PHP if ($multiuser) { ?>
<td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><?PHP if (!($print)) { ?><a href="category.php?updatecatsort=owner"><?PHP } ?>Owner</a></font></strong></td> 
<?PHP } ?>

  <td align="center" width="99%"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>"><?PHP if (!($print)) { ?><a href="category.php?updatecatsort=category"><?PHP } ?>Category name</a></font></strong></td>
<?PHP if (!($print)) { ?>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Modify</td>
  <td align="center"><strong><font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">Delete</td>
<?PHP } ?>
 </tr>
<?PHP
}

while ($categoryD = mysql_fetch_array($categoryR)) {
 if ($editcat == $categoryD["id"]) {
  $categoryname = "<input type=\"text\" name=\"category\" size=\"45\" value=\"".$categoryD["category"]."\">";
  if ($multiuser) {
   $oldCatOwnder = $categoryD["owner"];
   $r = qDB("SELECT username FROM $usertable ORDER BY username");
   $categoryowner = "<select name=\"owner\">";
   while ($userD = mysql_fetch_array($r)) {
    if ($userD[0] == $currentuser) { $SEL = "SELECTED"; } else { $SEL = ""; }
    $categoryowner = $categoryowner."<option $SEL value=\"".$userD[0]."\">".$userD[0]."\n";
   }
   $categoryowner = $categoryowner."</select>";
  } else {
   $noCatOwner = "<input type=\"hidden\" name=\"owner\" value=\"".$categoryD["owner"]."\">";
  }
  $modifyURL = "<input type=\"hidden\" name=\"updatecat\" value=\"".$categoryD["id"]."\">$noCatOwner<input type=\"submit\" value=\"Update\">";
  $categorysortTXT = "<select name=\"sort_number\">\n";
  for ($x = 1; $x <= $num_categories; $x++) {
   if ($categoryD["sort_number"] == $x) { $SEL = "SELECTED"; } else { $SEL = ""; }
   $categorysortTXT = $categorysortTXT."<option $SEL value=\"$x\">$x\n"; 
  }
  $categorysortTXT = $categorysortTXT."</select>\n";

 } else {
  $categoryname = $categoryD["category"];
  $categoryowner = $categoryD["owner"];
  $modifyURL = "  <a href=\"category.php?editcat=".$categoryD["id"]."\">Modify</font></td>";
  $categorysortTXT = $categoryD["sort_number"];
 }

?>
 <tr>
  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $categorysortTXT ?></font></td>

  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><nobr><?PHP echo substr($categoryD["created_date"],0,10) ?></nobr></font></td>

<?PHP if ($multiuser) { ?>
  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $categoryowner ?></font></td>
<?PHP } ?>

  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $categoryname ?></font></td>

<?PHP if (!($print)) { ?>

  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><?PHP echo $modifyURL ?></font></td>

  <td bgcolor="<?PHP echo $categoryBackCol ?>" align="center"><font face="<?PHP echo $pageFont ?>" color="<?PHP echo $categoryForeCol ?>" size="<?PHP echo $pageFontsize ?>"><a href="javascript:if(doublecheck()){ document.location.href='category.php?deletecat=<?PHP echo $categoryD["id"] ?>';}">Delete</font></td>
<?PHP } ?>
</tr>

<?PHP
 }
?>
</table>
</form>
<?PHP if ($editcat) { ?>
<script>
 document.editcategory.category.focus();
</script>
<?PHP } ?> 
</center>
</center>
<font face="<?PHP echo $pageFont ?>" size="<?PHP echo $pageFontsize ?>">
<?PHP
 $footerURL = $HTTP_REFERER;
 require 'footer.php';
?>
Return current item: ScreamingToDos