Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/admin/add_inline_cat.php
<?php
session_start();
/*
asaancart - easy shopping cart solution
---------------------------------------

Copyright 2009 Nasir Ahmad Khan
Email: hide@address.com

This file is part of asaancart - open source easy shopping cart solution.

asaancart is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

asaancart is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with asaancart.  If not, see <http://www.gnu.org/licenses/>.

*/

include("../config/config.php");
include("includes/chk_login_status_inc.php");

$category_name = $_GET['category_name'];
$parent_cat_id = $_GET['parent_cat_id'];
$category_description = $_GET['category_description'];

if($_GET['btn_create']=="Create")
{	
	if($category_name != ""){
		if($parent_cat_id=="root"){
			$sql = "INSERT INTO category (category_name, category_description) VALUES ('".$category_name."','".$category_description."')";
			$results = mysql_query($sql);
		}else{
		//enter cat
		$sql = "INSERT INTO category (category_name, category_description) VALUES ('".$category_name."','".$category_description."')";
		$results = mysql_query($sql);
		//get cat id
			$sql = "SELECT category_id FROM category WHERE category_name='$category_name'";
		$results = mysql_query($sql);
		
		while($row = mysql_fetch_array($results) )
		{
			$category_id = $row[0];		
		}
		//insert as sub cat
		$sql = "INSERT INTO sub_category (category_id, parent_cat_id) VALUES ($category_id, $parent_cat_id)";
		$results = mysql_query($sql);
		}
		
		$smarty->assign('msg_cat','Done: Created Successfully');
		$smarty->assign('newly_added_cat', $category_name);
	}else{
		$smarty->assign('msg_cat','Error: Please enter category name $category_name');
	}

}

//manage
$sql = "SELECT * FROM category ORDER BY category_name";
$results = mysql_query($sql);
$total_cat = mysql_num_rows($results);
$smarty->assign('total_cat', $total_cat);

while($row = mysql_fetch_assoc($results) )
{
	$all_categories[] = $row;		
}

$smarty->assign('all_categories', $all_categories);


//end manage

$smarty->display('category_select_box.tpl');
?>
Return current item: Simple PHP Shopping cart - asaancart