<?php
$login=mysql_connect("localhost","wauhaha_smart",'asd123');
mysql_select_db("wauhaha_smart");
$budget=$_REQUEST['budget'];


$q=mysql_query("SELECT * FROM company INNER JOIN product ON company.id = product.companyID AND pName like '%".$_REQUEST['product']."%' AND product.status='available' ORDER BY product.price ASC  ");

if($budget!=null){

 while($display=mysql_fetch_array($q)){
	   
	$price=(int)$display['price'];
	
	if($price<=$budget){
		$output[]=$display;
	
	}
	
				
	}
}else{


 while($display=mysql_fetch_array($q)){
	   
	
		$output[]=$display;
	
	
	
				
	}
}

    

print(json_encode($output));

mysql_close();
?>