Postingan lainnya
data yang sudh di inner join tidak masuk db
permisi saya mau tanya saya membuat form dimana terdapat data yg terinner join dan di inputkan secara langsung oleh member tapi data yg di inner join tidak mau masuk database bagaimana ya caranya agar bisa membuat form yang berisi data inner join dengan yg di inputkan sndiri dan saat saya mengisi form tersebut data yg terinner join akan muncul denagn otomatis mohon bantuannya..
model
class Pesan_model extends CI_Model{
function getAllPesan()
{
$this->db->select('pemesanan.*,daftar.*,mobil.*');
$this->db->join('daftar','daftar.id_member=pemesanan.id_member');
$this->db->join('mobil','mobil.no=pemesanan.no');
$this->db->from("pemesanan");
return $this->db->get();
}
function addPesan($data)
{
$this->db->insert('pemesanan', $data);
}
function deletePesan($id)
{
//delete produk berdasarkan id
$this->db->where('id_pesan', $id);
$this->db->delete('pemesanan');
}
}
tampilan
<input type="text" placeholder="Mobil" name="nama" >
<div class="main main-raised">
<div class="card card-nav-tabs">
<!--card header-->
<div class="card-header card-header-info">
<h1>Form Pemesanan
<small>Mobil</small><BR>
</h1>
</div>
<div class="card-body text-center">
<div class="card ">
<table class="table table-bordered table-striped table-hover">
<form method="post" action="<?= base_url() ?>index.php/pesan/addPesanDb">
<tr>
<td>Nama Lengkap
<?php echo $this->session->userdata('nama_lengkap') ?>
</td>
</tr>
<tr>
<td>Nama Mobil
<input type="text" placeholder="No Hp" name="nama" />
<!-- <?php echo $this->session->userdata('nama') ?> -->
</tr><br><br>
<tr>
<td>Harga
<input type="text" placeholder="No Hp" name="harga" />
<!-- <?php echo $this->session->userdata('harga') ?>
</td> -->
</tr><br><br>
<tr>
<td>No Hp
<input type="text" placeholder="No Hp" name="no_hp" />
</td>
</tr><br><br>
<tr>
<td>Tanggal Pesan
<input type="date" placeholder="Tanggal Pesan" name="tgl_pesan" />
</td>
</tr><br><br>
<tr>
<td>Jam Pesan
<input type="time" placeholder="Jam Pesan" name="jam_pesan" />
</td>
</tr><br><br>
<tr>
<td>Alamat
<input type="text" placeholder="Alamat" name="tujuan" />
</td>
</tr><br><br>
<tr>
<td>lama Sewa
<input type="text" placeholder="Lama Sewa" name="lama_sewa" />
</td>
</tr><br><br>
</table>
<input type="submit" value="Kirim" />
</thead>
<tbody>
</tbody>
</div>
</div>
</div>
</div>
</div>
controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Pesan extends CI_Controller {
function __construct(){
parent::__construct();
$this->load->helper('url','form');
$this->load->library(array('templuser'));
$this->load->library(array('template'));
$this->load->library('session');
$this->load->model("pesan_model");
}
public function index()
{
$data['listPesan'] = $this->pesan_model->getAllPesan();
$this->template->display('pesan/pesan_view', $data);
}
public function addPesan()
{
$this->templuser->display('pesan/add_pesan_view');
}
public function addPesanDb()
{
$data = array(
'id_member' => $this->session->userdata('nama_lengkap'),
'no' => $this->input->post('nama'),
'harga' => $this->input->post('harga'),
'no_hp' => $this->input->post('no_hp'),
'tgl_pesan' => $this->input->post('tgl_pesan'),
'jam_pesan' => $this->input->post('jam_pesan'),
'tujuan' => $this->input->post('tujuan'),
'lama_sewa' => $this->input->post('lama_sewa')
);
$this->pesan_model->addPesan($data);
redirect('pesan');
}
public function deletePesanDb($id_pesan)
{
$this->pesan_model->deletePesan($id_pesan);
redirect('pesan');
}
}
0
2 Jawaban:
Gan kalo ane liat itu $this->db->select nya salah gan.
Agan mau manggil database dari table mana?
Coba agan ganti jadi gini gan
<pre> $this->db->select('*') </pre>
0