admin page for category table


I found some info about creating a category table like this


The information shows a pre populated table similar to this


What I’m having trouble with is trying to picture how to put an admin page together to enter data into the database.

Has anyone done something like this that could shed some light on how it’s achieved?


I’m thinking forum script if I see your DB structure like that ;) Correct me if I’m wrong.

I’ve given it a try awhile ago. You could use dropdowns in a form to select a certain item’s ‘parent name’, which behind-the-scenes is being converted to the parent_id. Just loop through the DB entries to retrieve all of the available parents.


No it’s actually me reinventing the wheel to some extent. Not because I want to but because what exists won’t let me set it to what I require.

I’ts for a shopping cart of sorts. More a multi page/category order form. All that I need to do is email to base the number of items that people want of categorized products and all the rest is dealt with manually on site.

The website already exists but is needing to be redone to php/mysql from some other system, I’d send the link but it appears to be down right now

Basically it looks like this (Categories on the left, sub categories are used as headings with products coming underneath them. and the [ ] represents the box where you enter the quantity) (I had to edit the post as the layout did not stick, pretend the … are not there.0

SWEETS…Mars Bar [ ]
POPCORN…Pinky [ ]
…Roses [ ]
…Cadbury [ ]

There are a lot of good shopping cart systems out there but i have not found one where I can set it to do what I need, basically get rid of the pricing and just email number of items through. So I’m attempting to write my own.


using a form similiar to below:

<table width='100%' cellpadding=0 cellspacing=0 border=1 bordercolor='#eeeeee'><tr>
<form  name="frm" action="addcat.php" method="post"><td valign='top' align='center'>
<TD><input type="text" name="newcat" value=""></TD>
<TD><input type=submit value='Add Category' name='Submit'></TD>

to insert into your database you would use something like this below:
$query = “INSERT INTO class_item (id,sub,cat) VALUES (’’,’$cat_id’,’$newcat)”;
mysql_query($query) or die(‘Error, query failed’);
echo “[ Posted Successfully ]

Or to update use something like this:

$query = “UPDATE category_table SET sub = ‘$main_category_id’, cat = ‘$new_cat_name’”;
$result = mysql_query($query) OR die(mysql_error());

Or to delete use something like this:

$query = “DELETE FROM category_table WHERE id=’$id’”;
$result = mysql_query($query) OR die(mysql_error());

You might find this tutorial for a news script interesting here at

when I try to find information like this, I try to look up on for “php tutorial, mysql delete” or “php tutorial, mysql insert” or so on… without the quotes ( " ).

(if someone wants to correct me on any of the above, please do, dont claim to be perfect, but these should work.)

Now remember, this is only to add, update, and delete your categories, not how to show them on your page… or counting.