<?php session_start();
require_once("../config/config.php");
require_once("../validateuserlogin.php");
$myIp= ipCheck() ;
$dateceated=date("Y-m-d G:i:s");

$brand_name =$_REQUEST[SESS_MASTER.'brand_name'];
 $sqlbrand = "SELECT * FROM brand_filter";
	 
   	$myquerybrand=$conn->query($sqlbrand);
	$mydarabrand= $myquerybrand->fetchAll()  ;
	
	$rows_foundbrand = $myquerybrand->rowCount();
	
	$brand_name=explode(",",$brand_name);
	
if($rows_foundbrand==0){
    foreach($brand_name as $val){
    if(!empty($val)){
         $val=addslashes($val);
      $sqlu = "INSERT INTO brand_filter SET brand='$val'";
   	$myquerys=$conn->query($sqlu);
   	 header('location:../brand-store-master-page.php');
   
    } 
    
}

    
}else{
    $sqldel = "DELETE FROM brand_filter";
   	$myquerydel=$conn->query($sqldel);
     foreach($brand_name as $val){
    if(!empty($val)){
        $val=addslashes($val);
       $sqlu = "INSERT INTO brand_filter SET brand='$val'";
   	$myquerys=$conn->query($sqlu);
  	 header('location:../brand-store-master-page.php');
    } 
    
} 
  
    
    
}

print_r($brand_name);



       
       

       

 ?>