<?php 
	include('../config.php');          
	
	$stmt =  $conn->prepare("select id from all_cities WHERE  name=:name ");         
	$stmt->bindValue(':name', $_REQUEST['keyword1'], PDO::PARAM_STR); 
	$stmt->execute();   
	$city_id = $stmt->fetch(PDO::FETCH_OBJ);  
	
	$category_id = explode("-",$_REQUEST['keyword2']);  
	$city_tabel = 'city_tabel_'.$city_id->id;     
	
	if($_SESSION['month_salary_val'])
		$month_salary_val = "and max_salary >= ".$_SESSION['month_salary_val']; 
	else
		$month_salary_val = "";
	
	if($_SESSION['search_by_type_val'])
	{
		$test_array = explode(",",$_SESSION['search_by_type_val']); 
		array_pop($test_array); 
		
		foreach($test_array as $key=>$dt)
		{ 	
			if($key > 0) 
				$type .= " || type=".$dt; 
			else  
				$type .= "and (type=".$dt;
		}  
		$type .= ")";    
		
	}else
		$type = "";    
	
	
	echo "select * from $city_tabel  WHERE  category_id=:category_id  $type $month_salary_val ";
	$stmt =  $conn->prepare("select * from $city_tabel  WHERE  category_id=:category_id  $type $month_salary_val ");         
	$stmt->bindValue(':category_id', end($category_id), PDO::PARAM_INT);  
	//$stmt->bindValue(':type', $type2, PDO::PARAM_INT); 
	$stmt->execute();   
	$affected_rows = $stmt->rowCount();  
	if($affected_rows > 0)
		$all_jobs_result = $stmt->fetchAll(PDO::FETCH_OBJ);
	else
		$all_jobs_result  = null;   
	 
	
 
	foreach($all_jobs_result as $dt)
	{ 
?>

	<div style="border:1px solid;width:300px;align:center">
	 <h2><?php echo $dt->heading;?></h2>
	 <h2><?php echo $dt->min_salary. '  : '.$dt->max_salary;?></h2>
	</div>   

<?php 
	}  
?>   