Location: PHPKode > projects > PHP Gateway > e-comm/Cat/index.php
<?


if($_GET[changeprisub])
{
	$OK = Ineedcaffiene;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("UPDATE subcat SET TITLE = '".$_POST[title]."' where id = '".$_POST[id]."'");
	header("Location: index.php");
	print("Please go <a href='index.php'>Back</a> in order to make alterations.</a>");
	exit;
}
if($_GET[PRICATTOADD])
{
	$OK = Moo;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("INSERT INTO pricat (TITLE) VALUES ('".$_GET[PRICATTOADD]."')");
	print("<script language='jscript'>alert('Your Alterations have been Made. In order to continue you must go back to the main page.'); window.location.href = 'index.php';</script>");
	header("Location: index.php");
	print("Please go <a href='index.php'>Back</a> in order to make alterations.</a>");
	exit;
}
if($_GET[SubChange])
{
	$OK = Ineedcaffiene;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("UPDATE subcat SET TITLE = '".$_POST[SubCat]."' where ID = '".$_GET[catid]."'");
	header("Location: index.php");
	print("Please go <a href='index.php'>Back</a> in order to make alterations.</a>");
	exit;
}
if($_GET[EdSub])
{
	$OK = Value;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("delete from subcat where ID='".$_GET[EdSub]."'");
	header("Location: index.php");
	print("Please go <a href='index.php'>Back</a> in order to make alterations.</a>");
	exit;
}
if($_GET[AddSub])
{
	$OK = Moo;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("INSERT INTO subcat (TITLE, P_ID) VALUES ('".$_POST['newcat']."', '".$_GET['P_ID']."')");
	header("Location: index.php");
	print("Please go <a href='index.php'>Back</a> in order to make alterations.</a>");
	exit;
}
if($_GET[CatChange])
{
	$OK = Ineedcaffiene;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("UPDATE pricat SET TITLE = '".$_POST[PriCat]."' WHERE id = '".$_GET[catid]."'");
	print("<script language='jscript'>alert('Your Changes have been Made');</script>");
	print("You will have to go <a href='index.php'>Back to main</a> to do any more alterations.");
}

if($_GET[EdCat])
{
	$OK = Value;
	mysql_connect (localhost, ThinIce, justin);
	mysql_select_db (sportplus);
	mysql_query ("delete from pricat where ID='".$_GET[EdCat]."'");
	print("<script language='jscript'>alert('Your Changes have been Made');</script>");
	print("You will have to go <a href='index.php'>Back to main</a> to do any more alterations.");

}
if($_GET[Del])
{
		mysql_connect (localhost, ThinIce, justin);
		mysql_select_db (sportplus);
		mysql_query ("DELETE FROM subcat WHERE ID = '".$_GET[Del]."'");
}
if($_POST[id] == "No")
{
	print("<script language='jscript'>alert('You must select a category to edit first.');</script>");

}
if($_POST[id] && !$_GET[SubEdit])
{
	if($_POST[id] != "No")
	{

		mysql_connect (localhost, ThinIce, justin);
		mysql_select_db (sportplus);
		$result = mysql_query ("SELECT * FROM pricat WHERE id ='".$_POST[id]."'");
		print("<form action=?CatChange=1&catid=".$_POST[id]." method=post>");
		if ($row = mysql_fetch_array($result))
		{
			do
			{
				print "<small><b>Primary Category Title:</small></b><br>";
				print "<input type='text' name='PriCat' value='".$row[TITLE]."'>";
				print(" .:<small>[<a href=?EdCat=".$row[id].">Delete</a>]</small><br>");
			}while($row = mysql_fetch_array($result));
		}
		print("<input type=submit value='Change Title'></form>");
		$OK = OK;
		$result = mysql_query ("SELECT * FROM subcat WHERE P_ID = '".$_POST[id]."'");
			print("<small><b>Sub-Category Titles:</small></b><br>");
			if ($row = mysql_fetch_array($result))
			{
				do
				{
					print("<form action='?changeprisub=certainly' method=post>");
					print("<input type=text name='title' value='".$row[TITLE]."'>");
					print("<input type='hidden' name='id' value=".$row[id].">");
					print(" .:<small>[<a href='?DelSub=".$row[id]."&rep=".$_POST[id]."'>Delete</a>]</small> : <input type='submit' value='Update Title'>");
					print "</form>";
				}while($row = mysql_fetch_array($result));

		}
		print("<form action='?AddSub=Ja&P_ID=".$_POST[id]."' method=post>");
		print("<br><small><b>Add New Sub-Category:</b></small><br>");
		print("<input type=text name=newcat>");
		print("<br><input type='submit' value='Submit Changes'></form><br><small><br><a href='javascript:history.back()'>Back</a>");
	}
}


if(!$OK && !$_GET[Del] && !$_GET[DelSub])
{
	print("<B><BIG>Category Administration</b></big><br>");
	print("<pre>Please allow some time for refresh.</pre>");
	print("<br><b>Primary Categories:</b><br><br>");

	mysql_connect (localhost, ThinIce, justin);

	mysql_select_db (sportplus);

	$result = mysql_query ("SELECT * FROM pricat");
	print("<form action='index.php?Edit=".$_POST[id]."' method='post'>");
	print("<SELECT NAME = 'id'><OPTION VALUE = 'No' SELECTED>Select a Category to Edit</OPTION>");

	if ($row = mysql_fetch_array($result))
	{
		do
		{
			$selector = $row[id];
			print("<OPTION value='".$row[id]."'>".$row[TITLE]."</OPTION>");

		} while($row = mysql_fetch_array($result));

	}
	print("</SELECT><br>");
	print("<input type=submit value='Edit Selection'>");
	print("</form>");
	print("<b><small>Add Primary Category:</b></small>");
	print("<form action='index.php?CatAddPri=1fXo4h'>");
	print("<input type='text' name='PRICATTOADD'><br>");
	print("<input style='paddding:4px' type='submit' value='Submit Category'></form>");
}



	?>
Return current item: PHP Gateway