Location: PHPKode > projects > Helpdesk Over Web > how/sysmgmt/kbcats.php
<?php

// Administers Knowledgebase/Fault Categories

// Include Configuration File
require_once ('../includes/config.inc'); 

// Set the page title and include the HTML header.
$page_title = 'Helpdesk Over Web - Fault/Knowledgebase Category Admin';
include ('../includes/header.html');

if (isset($_POST['newkbcat'])) { // Check if the form has been submitted.
	// Connect to Database
	require_once ('../includes/mysql_connect.php');

	if (empty($_POST['newkbcat'])) {
		$newkbcat = FALSE;
		echo '<H4><font color="red">ERROR - New Category not Specified.</font></H4>';
		echo "<P>[ <A HREF='config.php'>Configuration Menu</A> ]</P>";
		include ('../includes/footer.html');
		mysql_close();		
		exit();
	} else {
		$assettype = $_POST['newkbcat'];
		$query = "INSERT INTO kbcategories (CategoryText) VALUES ('$newkbcat');";		
		$result = mysql_query($query)
		   or die("Invalid query: " . mysql_error());
		mysql_close();
		header ('Location: /how/sysmgmt/kbcats.php');	
		exit();
}
} 

// Connect to Database
require_once ('../includes/mysql_connect.php');

// Execute query to retrieve user details.
$sql = 'SELECT * FROM kbcategories ORDER BY CategoryText;';
$records = range(1, 500);
$result = mysql_query($sql)
   or die("Invalid query: " . mysql_error());
$num_rows = mysql_num_rows($result);

// Output query results in a table.
echo ("<H1>System Settings</H1><H3>Fault/Knowledgebase Categories Database</H3>");
echo ("<TABLE WIDTH='600'><TR><TD WIDTH='175'><b>Category Description</b></TD><TD><b>Click to Delete</b></TD></TR>");
while($i = mysql_fetch_row($result)) { 
	echo ("<TR>");
	echo ("<TD>$i[1]</TD>");
	echo ("<TD><A HREF='deletesetting.php?type=kbcat&id=$i[0]'>Delete</A></TD>");
	}
echo ("</TABLE>");
echo ("<H5>Add New Category</H5>");
echo "<FORM ACTION='kbcats.php' METHOD='post'><TABLE><TR><TD><b>Category Description</b>:</TD><TD><INPUT TYPE='text' LENGTH='52' MAXLENGTH='50' NAME='newkbcat'></TD></TR>";
echo "<TR><TD COLSPAN=2><input type='submit' name='submit' value='Add New Category' default></TD></TR></TABLE></FORM>";
echo "<P>[ <A HREF='config.php'>Configuration Menu</A> ]</P>";

// Include standard HTML footer
include ('../includes/footer.html');
mysql_close();
?>
Return current item: Helpdesk Over Web