0

我想在我的应用程序的日历类别中找到一个词,我设法在日历类别之外的搜索中找到一个词,我想问一下我的问题的正确代码是什么?

我的模型是这样的

function SearchResult($perPage, $uri, $judul) {
    $this->db->select('*');
    $this->db->where("IDKategori", $id);
    $this->db->from('kalender');
    if (!empty($judul)) {
        $this->db->like('judul', $judul);
    }
    $this->db->order_by('tanggalMulai', 'DESC');
    $getData = $this->db->get('', $perPage, $uri);

    if ($getData->num_rows() > 0)
        return $getData->result_array();
    else
        return null;
}

我的控制器是这样的

function pencarian_kategori($id) {
    if (isset($_POST['submit'])) {
        $data['judul'] = $this->input->post('judul');
        $this->session->set_userdata('sess_judul', $data['judul']);
    } else {
        $data['judul'] = $this->session->userdata('sess_judul');
    }
    $this->db->like('judul', $data['judul']);
    $this->db->where("IDKategori", $id);
    $this->db->from('kalender');

    $idk = $_POST[IDKategori];
    $pagination['base_url'] = base_url() . 'index.php/admin/kalenderkategori/pencarian_kategori/' . $this->uri->segment(4) . '/';
    $pagination['total_rows'] = $this->db->count_all_results();
    $pagination['full_tag_open'] = "<p><div class=\"pagination\">";
    $pagination['full_tag_close'] = "</div></p>";
    $pagination['cur_tag_open'] = "<span class=\"current\">";
    $pagination['cur_tag_close'] = "</span>";
    $pagination['num_tag_open'] = "<span class=\"disabled\">";
    $pagination['num_tag_close'] = "</span>";
    $pagination['first_link'] = 'Awal';
    $pagination['last_link'] = 'Akhir';
    $pagination['next_link'] = 'Selanjutnya';
    $pagination['prev_link'] = 'Sebelumnya';
    $pagination['per_page'] = "10";
    $pagination['uri_segment'] = 5;
    $this->pagination->initialize($pagination);
    $data['ListKalenderPencarian'] = $this->MKalender->SearchResult($pagination['per_page'], $this->uri->segment(5, 0), $data['judul']);

    $data['title'] = "Hasil Pencarian Agenda Pimpinan";
    $data['main'] = 'admin/kalender/kalender_pencarian';
    $this->load->vars($data);
    $this->load->view('layout/dashboard');
}

和我在 kalender_pencarian 中的看法是这样的

<form id="form_pencarian" name="form_pencarian" method="post" action="<?= base_url(); ?>index.php/admin/kalenderkategori/pencarian_kategori/<?= $this->uri->segment(4); ?>">
Pencarian Agenda Kegiatan =
<input name="judul" type="text" id="judul" size="30" maxlength="255" class="inputbox" value="<?= $judul; ?>"/>
&nbsp;&nbsp;
<input name="submit" type="submit" id="submit" value="Cari" class="button"/>
&nbsp; <strong>( Berdasarkan Judul )</strong></form><br />

<?php function DateToIndo($date) { $kategoriIndo = array("Jan", "Feb", "Mar",
    "Apr", "Mei", "Jun",
    "Jul", "Agus", "Sep",
    "Okt", "Nov", "Des");
$tahun = substr($date, 0, 4);
$kategori = substr($date, 5, 2);
$tgl = substr($date, 8, 2);
$jam = substr($date, 11, 8);
$result = $tgl . " " . $kategoriIndo[(int) $kategori - 1] . " " . $tahun . " " . $jam;
return($result); }  if ($this->session->flashdata('message')) {
echo "<div class='message'>" . $this->session->flashdata('message') . "</div>"; } if (count($ListKalenderPencarian)) { echo "<table border='1' cellspacing='0' cellpadding='3' width='100%'>\n";
echo "<tr valign='top'>\n";
echo "
        <th><div align='center'>Kegiatan</th>
        <th><div align='center'>Waktu Mulai</th>
        <th><div align='center'>Waktu Akhir</th>
        <th><div align='center'>Pilihan</th>\n";
echo "</tr>\n";
foreach ($ListKalenderPencarian as $key => $list) {
    echo "<tr valign='top'>\n";
    echo "<td>" . $list['judul'] . "&nbsp;</td>\n";
    echo "<td>" . DateToIndo($list['TanggalMulai']) . "&nbsp;</td>\n";
    echo "<td>" . DateToIndo($list['TanggalAkhir']) . "&nbsp;</td>\n";
    echo "<td nowrap><div align='center'>"; ?>
<a href ="<?= base_url(); ?>index.php/admin/kalender/ubah_lagi/<?= $list['IDKalender']; ?>/<?= $this->uri->segment(4); ?>">Ubah</a> |
    <a href ="<?= base_url(); ?>index.php/admin/kalender/hapus_lagi/<?= $list['IDKalender']; ?>/<?= $this->uri->segment(4); ?>">Hapus</a>
<?php echo "</td>\n"; echo "</tr>\n"; } echo "</table>"; } 
echo '<div class="pagination">' . $this->pagination->create_links() . '</div>' ?>
4

0 回答 0