Postingan lainnya
Bagaimana cara membuat search %Like% dengan codeigniter?
[ASK] Bagaimana cara membuat search %Like% dengan codeigniter?
Mohon bantuannya...
2
13 Jawaban:
Jawaban Terpilih
contoh filter tahun-bulan (2017-01)
$this->db->where('tanggal LIKE',$tahun.'-'.$bulan.'%');
1
Controller :
[img] https://snag.gy/1tpZ9v.jpg [/img]
Model :
Views :
Tolong pencerahannya gann @gunalirezqimauludi ...
2
scriptnya di posting aja, ga terlalu kebaca... coba print_r($results); di viewnya
1
COntroller :
function search() {
$keyword = $this->input->post('cari'); //tergantung namenya apa
$data['results'] = $this->Post_model->cari($keyword);
$this->load->view('v_feedback',$data);
}
Model :
public function cari($keyword)
{
$query = $this->db->query("SELECT * FROM tbfeedback WHERE email LIKE '%$keyword%'");
$this->db->like('email', $keyword);
//$query = $this->db->get('tbfeedback');
return $query->result();
}
Views :
<?= print_r($data['results']); ?>
<div class="container">
<div class="content">
<h1>Feedback :</h1>
<br><br>
<a href="<?= base_url('home/kasih_feedback/caridata'); ?>" class="add info"><b>[ + ]</b></a>
<form action="<?= base_url('home/feedback/search'); ?>" method="POST" style="float: right;">
<input type="text" name="cari" placeholder="Cari disini..">
<?= form_error('cari'); ?>
<input type="submit" name="submit" value="cari">
</form>
<br><br>
<table>
<thead>
<tr>
<th>Nama Customer</th>
<th>Email</th>
<th>Pesan</th>
<th>Date</th>
<th>Aksi</th>
</tr>
</thead>
<tbody>
<?php if (!empty($record)): ?>
<?php foreach ($record as $row): ?>
<td><?= $row['nama']; ?></td>
<td><?= $row['email']; ?></td>
<td><?= $row['pesan']; ?></td>
<td><?= $row['date']; ?></td>
<td></td>
<td>
<a href="<?= base_url('home/balas_feedback/' . $row['id']); ?>"
class="btn-aksi success">Balas</a> <br>
<a href="<?= base_url('home/delete_data/' . $row['id']); ?>"
class="btn-aksi warning">Hapus</a>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
2
apa di controller $data['results'] = $this->Post_model->cari($keyword); emang ga ada nilainya ?
2
Array ( ) 1
pas di print_r($results);
2
akhirnya ada secercah titik terang juga gan..
setelah stuck ber jam-jam...
2
jadi udah bisa skrng? apanya yg diubah?
1
kalau mencari data dalam banyak tabel gimana?
0