Location: PHPKode > projects > Simple PHP Shopping cart - asaancart > asaancart v-0.9/admin/add_inline_attributes.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");

$attribute_name = $_GET['attribute_name'];
$attribute_value = $_GET['attribute_value'];
$set_id = $_GET['set_id'];

if($_GET['btn_create']=="Create")
{	
	
		$sql = "SELECT * FROM attribute WHERE attribute_name='$attribute_name'";
		$results = mysql_query($sql);
		$total_cat = 0;
		$total_cat = mysql_num_rows($results);
		if($total_cat == 0){
			$sql = "INSERT INTO attribute (attribute_name) VALUES ('".$attribute_name."')";
			$results = mysql_query($sql);
			//$smarty->assign('msg_cat','Done: Created Successfully');
		}
		
		//get attribute id just created
		$sql = "SELECT * FROM attribute WHERE attribute_name='$attribute_name'";
		$results = mysql_query($sql);
		$total_cat = 0;
		while($row = mysql_fetch_assoc($results) )
		{
			$attribute_id = $row['attribute_id'];		
		}
		
		//insert into attribute set value
		$sql = "INSERT INTO attribute_set_value (attribute_name, attribute_id, set_id) VALUES ('".$attribute_name."', $attribute_id, $set_id)";
		$results = mysql_query($sql);
		
		//insert value into value attibute tab
		//insert into attribute set value
		$sql = "INSERT INTO attribute_value (attribute_value, attribute_id) VALUES ('".$attribute_value."', $attribute_id)";
		$results = mysql_query($sql);

}

//get attribute set value list

	$sql = "SELECT * FROM attribute_set_value WHERE set_id=$set_id";
	$results = mysql_query($sql);
	$total_attribute_set_value = mysql_num_rows($results);

	while($row = mysql_fetch_assoc($results) )
	{	
	//echo "<br>-------------------<br>"; //attribute_set_value table fields
	$all_attribute_set_id[] = $row;
	//echo $row['set_id']. " ==== ".$row['attribute_name']."<br>";
	
			$sql2 = "SELECT * FROM attribute_value WHERE attribute_id=".$row['attribute_id'];
			$results2 = mysql_query($sql2);
			while($row2 = mysql_fetch_assoc($results2) )
			{
				$all_attribute_set_value[] = $row2;
				//echo $row2['attribute_id']. " === ".$row2['attribute_value']."<br>";
			}	
	
	}
	
	$smarty->assign('all_attribute_set_value', $all_attribute_set_value);
	//$smarty->assign('set_id', $set_id);
	$smarty->assign('all_attribute_set_id', $all_attribute_set_id);
	$smarty->assign('attribute_set_id', $set_id);

//end attribute set value list

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