<? include("header.php");

include("include/db-connect.php");
$id=$_GET['id'];


//....Tamil font......
mysql_query("SET character_set_results = 'utf8', character_set_client = 'utf8', character_set_connection = 'utf8', character_set_database = 'utf8', character_set_server = 'utf8'");
//.................

	if(isset($_POST['submit']))
	{
	    $category_name=$_REQUEST['category_name'];
		  
		
		  
		$id=$_GET['id'];
  
		$select="select * from  ".$CAT." where id='$id'";
		$run=mysql_query($select);
		$row = mysql_fetch_array($run);
		$cat=$row['category_name'];
		  
		$select1="select * from  sub_category where cat_name='$cat'";
		$run1=mysql_query($select1);
		$row1 = mysql_fetch_array($run1);
		$cat1=$row1['cat_name'];
		$subcat=$row1['subcat'];
		$upd_qur1="UPDATE sub_category SET  cat_name= '$category_name' WHERE cat_name='$cat'"; 
		$exe_pag1=mysql_query($upd_qur1);  
		  
		$upd_qur2="UPDATE products SET category='$category_name' WHERE category='$cat'"; 
		$exe_pag2=mysql_query($upd_qur2);    
		  
		$upd_qur="UPDATE ".$CAT." SET  category_name = '$category_name' WHERE `id` ='$id'";  
		$exe_pag=mysql_query($upd_qur);
		
		?>
        <script>
		window.location='view_cat.php?edit=sucess';
		</script>
        <?		
	} 
	?>  
 

<div id="content">
  <div class="breadcrumb">
       <!-- <a href="http://amarasudhan.com/admin/index.php?route=common/home&amp;token=b735cc089ec2d51abb9a8e1901f501fb">Home</a>-->
      </div>
              <div class="box">
    <div class="heading">
      <h1><img src="view/image/home.png" alt="" />Edit Category</h1>
    </div>
    <div class="content">
      <div class="overview" style="width:50%; margin-left:300px;">
        <div class="dashboard-heading">  category</div>
        <div class="dashboard-content">
        
 <?php

$query = mysql_query("select * from ".$CAT." where id = '".$id."' ");
$array=mysql_fetch_array($query);

?>
 
 <?php if($_REQUEST['ed']=='su'){ echo "<div class='alert_succes'>Contact Edited Successfully</div>"; } else { echo "";}?>

 <form action="" method="post" enctype="multipart/form-data" id="client" >
  <!--<script type="text/javascript" src="../prototype.js"></script> 
  <script type="text/javascript" src="../validation.js"></script>
  -->
  
  
                     
	                 
            <div class="mainrow" style="margin-left:100px;">

                <div class="maintext" style="width:150px;">Category Name <font color="#FF0000"><b> *</b></font> </div>

                <div class="maintextbox"><input type="text" name="category_name" size="36" class="required" value="<?php echo $array['category_name'];  ?>"></div>

            </div>
            
           
            
            <br />
               <div class="mainrow" style="margin-left:100px;">

             <div class="maintext" style="width:150px;"> </div>

              <div class="maintextbox"><input  id="Submit" type="submit" value="Submit" name="submit" /><br><br>
              <a href="view_cat.php"><img src="images/bac.jpg"></a></div>
              

            </div>		
               
			    </form>
        </div>
      </div>
      
      
    </div>
  </div>
</div>
<!--[if IE]>
<script type="text/javascript" src="view/javascript/jquery/flot/excanvas.js"></script>
<![endif]--> 
<script type="text/javascript" src="view/javascript/jquery/flot/jquery.flot.js"></script> 
<script type="text/javascript"><!--
function getSalesChart(range) {
	$.ajax({
		type: 'get',
		url: 'index.php?route=common/home/chart&token=b735cc089ec2d51abb9a8e1901f501fb&range=' + range,
		dataType: 'json',
		async: false,
		success: function(json) {
			var option = {	
				shadowSize: 0,
				lines: { 
					show: true,
					fill: true,
					lineWidth: 1
				},
				grid: {
					backgroundColor: '#FFFFFF'
				},	
				xaxis: {
            		ticks: json.xaxis
				}
			}

			$.plot($('#report'), [json.order, json.customer], option);
		}
	});
}

getSalesChart($('#range').val());
//--></script> 
</div>
<?  include("footer.php"); ?>