Welcome Guest, Not a member yet? Register   Sign In
[HELP] sql depends to another sql
#1

[eluser]C_Line[/eluser]
i have a code like this

Code:
controller
function ambil_dataUser($value)
{
$this->load->model("Query_barang",'',TRUE);
$data['query'] = $this->Query_barang->ambil_data_users($value);
$data['id_us'] = $value;
$this->load->view('home_admin');
$this->load->view("liat_transuser",$data);
}

model
function ambil_data_users($id)
{
$query = $this->db->query("select * from transaksi_users where id_users = '$id'")->result();
return $query;
}


view
foreach($query as $hsl){ // <-- this code used to retrieve id and transaction number


$querys = $this->db->query("select t.id_users,t.status_transaksi,t.tanggal_pesan,b.id_barang,b.nama_barang,b.harga,b.berat,s.qty
from transaksi_users t,barang b, shopcart_user s
where t.id_users = '$hsl->id_users' and t.notrans_users = $hsl->notrans_users and s.notrans_users = t.notrans_users and b.id_barang = s.id_barang")->result();

foreach($querys as $row)
{
echo "<tr><tD>$row->nama_barang</td></tr>";
}}



ex: i have 2 transaction like id = 1 and id = 2
on $querys i can't use it in model because it always return the last value
so i put that code in view, please help,, thx


Messages In This Thread
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 08:13 PM
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 11:15 PM
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 11:27 PM
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 11:30 PM
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 11:34 PM
[HELP] sql depends to another sql - by El Forum - 07-15-2012, 11:48 PM
[HELP] sql depends to another sql - by El Forum - 07-16-2012, 12:51 AM
[HELP] sql depends to another sql - by El Forum - 07-16-2012, 05:09 AM
[HELP] sql depends to another sql - by El Forum - 07-16-2012, 05:26 AM



Theme © iAndrew 2016 - Forum software by © MyBB