bu link üzerinden çalışan halini kontrol edebilirsin.

ayrıca buradan dosyaları indire bilirsin.

javascript kodu :


<script></script>
<script>
var filter = function (){

var url = "http://kodarsiv.com/surectakip/ajaxFilter.php";

function ajaxSender($data) {
$.post(url, $data, function (response) {
dataParser(response);
});
}

function dataParser(data) {
var obj = jQuery.parseJSON(data);
$("div.sonuc").find("ul").html("Sorumlu : " + obj[0]["sorumlu"] + " - hedef : "+ obj[0]["hedef"]);
console.log(obj);
}

return {
onChange : function () {
data = {};
$("select#surec").on("change", function () {
data["ssa"] = $(this).val();
ajaxSender(data);
});

$("select#gos").on("change", function () {
data["gos"] = $(this).val();
ajaxSender(data);
});
}
}
}();


$(document).ready(function () {
filter.onChange();
});
</script>


filtre kodu :

require_once __DIR__."/vendor/autoload.php";
use Illuminate\Database\Capsule\Manager as Capsule;

$capsule = new Capsule;

$capsule->addConnection([
'driver' => 'mysql',
'host' => 'localhost',
'database' => 'surecdb',
'username' => 'surecuser',
'password' => 'psword',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
]);

use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$capsule->setEventDispatcher(new Dispatcher(new Container));

$capsule->setAsGlobal();

$capsule->bootEloquent();
$liste = Capsule::table('liste');

if ( isset($_POST["ssa"]) ) {
$liste->where("ssa", $_POST["ssa"]);
}

if( isset($_POST["ssa"]) && isset($_POST["gos"]) ) {
$liste->orWhere("gos", $_POST["gos"]);
}else if( !isset($_POST["ssa"]) && isset($_POST["gos"]) ) {
$liste->where("gos", $_POST["gos"]);
}

$data = $liste->get();

print_r(json_encode($data, true));