<?php include 'open_connection.php'; ?>
	  <?php
       $vendor_id = $_REQUEST['vendor_id'];

echo $vendor_id;

       $sql = "select tbl_dir_evendor.vendor_id, tbl_dir_evendor.vendor_name, tbl_dir_evendor.vendor_address1,tbl_dir_evendor.vendor_address2,tbl_dir_evendor.vendor_contact,  		
	   		   tbl_dir_evendor.vendor_hp1,tbl_dir_evendor.vendor_hp2,tbl_dir_evendor.vendor_fax,tbl_dir_evendor.vendor_email,tbl_dir_evendor.category_name,
			   tbl_dir_evendor.subCategory_name,tbl_ref_ecategory.category_id,tbl_ref_ecategory.category_name,tbl_ref_esubcategory.SubCategory_id,
               tbl_ref_esubcategory.subCategory_name
       		   from tbl_dir_evendor
			   Left join  tbl_ref_ecategory ON tbl_dir_evendor.category_name=tbl_ref_ecategory.category_name
			   Left Join  tbl_ref_esubcategory ON tbl_dir_evendor.subCategory_name=tbl_ref_esubcategory.subCategory_name
			   where  vendor_id= '$vendor_id'";
																		
				$result = mysql_query($sql) or die('Query failed. ' . mysql_error());
				// $row = mysql_fetch_array($result, MYSQL_ASSOC);
				
				$row=mysql_fetch_array($result);
			    $vendor_id=$row['vendor_id'];
				$subCategory_name=$row['subCategory_name'];
			 
		?>
<?php
     $category_name = $_POST['category_name'];
  $subCategory_name = $_POST['subCategory_name'];
             $type= $_POST['type'];
 
if (isset($_GET['page'])) 
		{ 
			$page = $_GET['page']; 
		} 
		else 
		{ 
			$page = 1; 
		}
		$start_from = ($page-1) * 10; 
$listcat = mysql_query("SELECT category_name FROM tbl_ref_ecategory");
//$cat_id = mysql_query("Select category_id form tbl_ref_ecategory where category_name='$listcat'");
$listsub = mysql_query("SELECT  tbl_ref_esubcategory.subCategory_name from tbl_ref_esubcategory 
Left join  tbl_ref_ecategory ON tbl_ref_esubcategory.category_name=tbl_ref_ecategory.category_name
where 
tbl_ref_ecategory.category_name='$category_name' ");
//$listitem = mysql_query("SELECT * FROM item ORDER BY subcategoryname ASC LIMIT $start_from, 10");

//$sub_id = mysql_query("Select SubCategory_id form tbl_ref_esubcategory where SubCategory_name='$listsub'");
?>
<form method="post">
<table border=0 align=center  class="imagetable" width="52%"> <tr>

<input type="text" size="100" name="subCategory_name" value="<?php echo $row['subCategory_name'];?>">
        <td>Category </td><td> : </td>
        <td><label> 
		<br>
         <select id='category_name' name="category_name" onchange="submit()">
            <?php 
		 if ($category_name != "" )
 {
 ?>
            <strong><?php echo '<option selected="selected" value="'.$row['category_name'].'">'.$row['category_name'].'</option>';?></strong>
            <?php
 }
		else
		{
		echo '<option selected="selected" value="'.$row['category_name'].'">'.$row['category_name'].'</option>';
		}
		while($row = mysql_fetch_array($listcat))
  {
  echo '<option value="'.$row['category_name'].'">'.$row['category_name'].'</option>';
 }	
 
  ?>
          </select>
		  
        </label></td>
      </tr><?php echo $row['subCategory_name'];?>
      <tr>
        <td>Sub-Category</td><td> : </td>
        <td><label>
		<br>
		<?php echo $row['subCategory_name']?>
          <select id='subCategory_name' name="subCategory_name" >
            <?php 
		 if ($subCategory_name != "" )
 {
 ?>
            <strong><?php echo '<option selected="selected" value="'.$subCategory_name.'">'.$subCategory_name.'</option>';?></strong>
            <?php
 }
		else
		{
		echo '<option selected="selected" value="'.$row['subCategory_name'].'">'.$row['subCategory_name'].'</option>';
		}
		while($row = mysql_fetch_array($listsub))
  {
  echo '<option value="'.$row['subCategory_name'].'">'.$row['subCategory_name'].'</option>';
 }	
 
  ?>
          </select>
        </label>        
		</td>
      </tr>
		
					</td></tr>
					</table></form>
  <p>
  
  </p>
</div>
</body>
</html>
