Location: PHPKode > projects > PHP Simple FAQ > phpsimplefaq1.1beta/phpsimplefaq/includes/admin_category.inc.php
<?

// PHP Simple FAQ Category admin page v1.0


if (($add) && ($category)) 

	{
		$new_sql = "INSERT INTO $database_name.$category_table (category, category_creator, faq_id)
					VALUES ('$category', '$new_cat_creator', '$faq_id')";
		mysql_query($new_sql,$connection);
	}
	
if ($remove) 

	{
		$remove_sql = "DELETE FROM $database_name.$category_table 
					   WHERE cat_id='$remove'";
		mysql_query($remove_sql,$connection);
	}

$sql = "SELECT * 
		FROM $database_name.$category_table
		ORDER by faq_id";
$result = mysql_query($sql,$connection);
$sql5 = "SELECT * 
		 FROM $database_name.$user_table
		 WHERE user_email='$email'";
$result5 = mysql_query($sql5,$connection);
$myrow5 = mysql_fetch_array($result5);
$creator = $myrow5["user_id"];	
									
?>
<br>
<center>				
<table border="0" width="100%" cellspacing="2" cellpadding="2">
	<tr>
		<td colspan="2"><center><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\"><B>$manage_categories_lang</b><br>"; ?>
		<? if (($add) && ($category)) echo "<font color=\"red\">$cat_created_lang</font>";
		   if ($remove) echo "<font color=\"red\">$cat_deleted_lang</font>"; ?></font></center></td>
	</tr>
</table>
<br>
		<table width="90%" cellpadding="4" cellspacing="2" bgcolor="#333366"> 
			<tr>
				<td align="LEFT" bgcolor="#3366CC" width="20%"><b><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\">$faq_lang</FONT></B></TD>"; ?>
				<td align="LEFT" bgcolor="#3366CC"><b><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\">$category_lang</FONT></B></TD>"; ?>
				<td align="LEFT" bgcolor="#3366CC" width="100"><b><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\">$creator_lang</FONT></B></TD>"; ?>
				<td align="CENTER" bgcolor="#3366CC" width="100"><b><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\">$delete_lang</FONT></B></TD>"; ?>
			</TR>
			<?	while ($myrow=MySQL_fetch_array($result)) 
			
					{
						$cat_id = $myrow["cat_id"];
						$faq_id = $myrow["faq_id"];
						$category = $myrow["category"];
						$cat_creator = $myrow["category_creator"];
						$sql2 = "SELECT user_name
								 FROM $database_name.$user_table
								 WHERE user_id='$cat_creator'";
						$result2 = mysql_query($sql2,$connection);
						$myrow2 = mysql_fetch_array($result2);
						$creator_nick=$myrow2["user_name"];
						
						$sql3 = "SELECT faq_title
								 FROM $database_name.$faq_table
								 WHERE faq_id='$faq_id'";
						$result3 = mysql_query($sql3,$connection);
						$myrow3 = mysql_fetch_array($result3);
						$faq_title=$myrow3["faq_title"];
				 ?>
			<tr>
				<td align="LEFT" valign="TOP" bgcolor="#CCCCCC" width="20%"><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">$faq_title"; ?></FONT></TD>
				<td align="LEFT" valign="TOP" bgcolor="#CCCCCC"><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">$category"; ?></FONT></TD>
				<td align="LEFT" valign="TOP" bgcolor="#CCCCCC" width="100"><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">$creator_nick"; ?></FONT></TD>
				<td align="CENTER" valign="TOP" bgcolor="#CCCCCC" width="100"><? echo "<form method=\"post\" action=\"manage_faq.php?action=categories&remove=$cat_id\">";
					   echo "<INPUT TYPE=\"hidden\" NAME=\"email\" VALUE=\"$email\">";
					   echo "<INPUT TYPE=\"hidden\" NAME=\"password\" VALUE=\"$password\">";
					   echo "<INPUT TYPE=\"hidden\" NAME=\"admin\" VALUE=\"yes\">";
					   echo "<INPUT TYPE=\"submit\" NAME=\"Submit\" VALUE=\"$delete_lang\">";
					   echo "</FORM>"; ?></td>
			</tr>
				<? } ?>
			<tr>
				<td valign="TOP" align="LEFT" bgcolor="#3366CC" width="20%"><form name="form2" method="post" action="manage_faq.php?action=categories&add=yes"><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\" color=\"#FFFFFF\"><b>$new_category_lang:</b><br>"; ?>
				</font></td>
				<td valign="middle" align="LEFT" bgcolor="#CCCCCC" colspan="2"><? echo "<font face=\"$font_face\" size=\"$font_size\" class=\"$font_class\">$faq_lang&nbsp;&nbsp;"; ?>
				<select name="faq_id" width="35">
				<? 
				$sql4 = "SELECT *
						 FROM $database_name.$faq_table";
				$result4 = mysql_query($sql4,$connection);
				while ($myrow4=MySQL_fetch_array($result4)) 
				
					{
						$faq_title=$myrow4["faq_title"];
						$faq_id=$myrow4["faq_id"];
						echo "<option value=\"$faq_id\">$faq_title</OPTION>";
					}
					
				?>
				</SELECT>&nbsp;&nbsp;
				<input type="text" name="category"></td>
				<td valign="TOP" align="CENTER" bgcolor="#CCCCCC" width="100">
				<?
				echo "<INPUT TYPE=\"hidden\" NAME=\"email\" VALUE=\"$email\">";
				echo "<INPUT TYPE=\"hidden\" NAME=\"password\" VALUE=\"$password\">";
				echo "<INPUT TYPE=\"hidden\" NAME=\"admin\" VALUE=\"yes\">";
				echo "<INPUT TYPE=\"hidden\" NAME=\"new_cat_creator\" VALUE=\"$creator\">";
				?>
				<input type="submit" name="submit" value="<? echo "$add_category_but_lang"; ?>"></TD>
			</tr>
		</table>
	</center>

				
				
				
Return current item: PHP Simple FAQ