过滤器无法完全正常运行

时间:2019-09-06 06:44:23

标签: php filter

我正在为我的网页使用一个过滤器,该过滤器可以在其中搜索多个内容,但只能搜索可以使用的名称

<form method="post" class="form-inline">

<input  class="form-control" type="text" name="keyword" id="keyword" placeholder="nama">
<input  class="form-control" type="text" name="pkt" id="pkt" placeholder="paket">
<br><br>
<label for="nama" class="col-sm-2 col-form-label">waktu awal</label>
<input  class="form-control" type="date" name="from" id="from">
<br><br>
<label for="nama" class="col-sm-2 col-form-label">waktu akhir</label>
<input  class="form-control" type="date" name="to" id="to">
<br><br>
<input class="btn" type="submit" name="cari" value="search">
<?php
include "koneksi.php";
if (isset($_POST['cari'])) {
    //search qry
    $keyword = $_POST['keyword'];
    $pkt = $_POST['pkt'];
    $from = $_POST['from'];
    $to = $_POST['to'];
    $sql =
        "SELECT tb_peserta.id_peserta,tb_data.nama,tb_paket.nama_paket,tb_peserta.ket,tb_peserta.waktu_awal,tb_peserta.waktu_akhir
FROM tb_peserta,tb_data,tb_paket
WHERE  tb_peserta.status_data_peserta='aktif'
AND tb_peserta.id_number=tb_data.id_number
AND tb_peserta.id_paket = tb_paket.id_paket
AND (tb_data.nama LIKE '%$keyword%' OR tb_paket.nama_paket LIKE '%$pkt%' OR tb_peserta.waktu_awal LIKE '%$from%'  OR tb_peserta.waktu_akhir LIKE '%$to%')";
}

0 个答案:

没有答案