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

[eluser]C_Line[/eluser]
i have a query like this in view




Code:
echo "<tr><td colspan=2><br /><table width=800>";
echo "<tr><td>ID Barang</td>";
echo "<td>Nama Barang</td>";
echo "<td>Harga</td>";
echo "<td>Berat</td>";
echo "<td>Qty</td>";

$querys = $this->db->query("select t.harga_tarif,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(); // <--this code
$tot_brt = 0;
foreach($querys as $row)
{
echo "<tr><td>$row->id_barang</td>";
echo "<td>$row->nama_barang</td>";
echo "<td>$row->harga</td>";
echo "<td>$row->berat</td>";
echo "<td>$row->qty</td></tr>";
$brt = $row->berat*$row->qty;
$tot_brt += $brt;
$harga = $row->harga * $row->qty;
$total = $total + $harga;
$tarif = $row->harga_tarif;
}

is that ok ? that i use query in view to retrieve vlaue from database ? bcause i dun know what must i do to that query, if i put that in view, its work, but if i put it in model, it won't work


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