<?php

require_once("connectioni.php");
	
 
// 	$sql="select * from userpermission group by docid"; 
// 	$result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
// 	while ($row = mysqli_fetch_array($result)){
		
// 		$sql1="select * from doc where docid='".$row["docid"]."'";
// 		$result1 =mysqli_query($GLOBALS['dbinv'],$sql1) ; 
// 		$row1 = mysqli_fetch_array($result1); 

// 		$sql2 = "update userpermission set doc_name= '" . $row1['docname'] . "'   where docid='".$row["docid"]."'";
// 		$result2 = mysqli_query($GLOBALS['dbinv'], $sql2);
		 
// 	}
	
	
		$sql="select * from s_salma  "; 
	$result =mysqli_query($GLOBALS['dbinv'],$sql) ; 
	while ($row = mysqli_fetch_array($result)){
		 
		
		
	    $sql2 = mysqli_query($GLOBALS['dbinv'], "select * from vendor where CODE='".$row["C_CODE"]."'") or die(mysqli_error());
        if ($row2 = mysqli_fetch_array($sql2)) {
            //  echo $row['C_CODE'].'<br>';
        }else{
            // echo $row['C_CODE'].'<br>';
            
        	$sql3 = "Insert into vender_sub (c_code, c_name,c_main,type,town)values 
			('" . $row['C_CODE'] . "', '" . $row['CUS_NAME'] . "','" . $row['C_CODE'] . "','M','1') "; 
          $result3 = mysqli_query($GLOBALS['dbinv'], $sql3);
          
          $sql3 = "Insert into vendor (CODE, NAME,OPBAL,CAT)values 
			('" . $row['C_CODE'] . "', '" . $row['CUS_NAME'] . "','1','C') "; 
          $result3 = mysqli_query($GLOBALS['dbinv'], $sql3);
        }
		 
	}

?>

