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

[eluser]InsiteFX[/eluser]
Try this should give you an idea.

model
Code:
function ambil_data_users($id)
{
    $html = '';

    $query = $this->db->query("select * from transaksi_users where id_users = '$id'")->result();

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)
{
    $html .= "<tr><td>$row->nama_barang</td></tr>\t\n";
}}

return $html;

Controller
Code:
$data['html'] = $this->Query_barang->ambil_data_users($value);

// view
&lt;?php echo $html; ?&gt;


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