1- Sessionda bulunan firma id:
$_SESSION['yep_users']['company_id'];2- Selectbox dan gelen aramayı gönderdiğim ajax kodu:
<script>
$(document).ready(function(){
$("#products_category").select2({
ajax: {
url: "db/yep-ajax.php",
type: "post",
dataType: 'json',
delay: 250,
data: function (params) {
return {
searchTerm: params.term // search term
};
},
processResults: function (response) {
return {
results: response
};
},
cache: true
}
});
});
</script>3 - Karşıladığım PHP sayfası:if(!isset($_POST['searchTerm'])){
$sql=$db->qSQL("select * from yep_products_cagetories order by yep_products_cagetories_name limit 5");
}
else {
$search = $_POST['searchTerm'];
$sql=$db->qSQL("select * from yep_products_cagetories where yep_products_cagetories_name like '%".$search."%' limit 5");
}
$data = array();
while ($row=$sql->fetch(PDO::FETCH_ASSOC)) {
$data[] = array("id"=>$row['yep_products_cagetories_id'], "text"=>$row['yep_products_cagetories_name']);
}
echo json_encode($data);