• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Help] retrive multiple value from database

i wan to print value from database

here's my code

function ambil_dataUser($value)
$data['query'] = $this->Query_barang->ambil_data_users($value);
$data['detail_cart'] = $this->Query_barang->detail_shopcart($value);
$data['id_us'] = $value;

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

function detail_shopcart($user_ids)
$querys = $this->db->query("select * from transaksi_users where id_users = '$user_ids'")->result();
foreach($querys as $hsl){
$no = $hsl->notrans_users;
$query = $this->db->query("select t.id_users,t.status_transaksi,t.tanggal_pesan,b.id_barang,b.nama_barang,b.harga,
from transaksi_users t,barang b, shopcart_user s
where t.id_users = '$user_ids' and t.notrans_users = $no and s.id_users = t.id_users
and b.id_barang = s.id_barang")->result();
return $query;

foreach($query as $hsl){
echo "<tr><td>Status : </td><td><select name='pilih_status'>";
if($hsl->status_transaksi == "Belum Lunas"){ // CEK Selected
echo "<option value='Belum Lunas' selected='selected'>Belum Lunas</option>";
echo "<option value='Lunas'>Lunas</option>";
echo "</select></td></tr>";
echo "<option value='Lunas' selected='selected'>Lunas</option>";
echo "<option value='Belum Lunas'>Belum Lunas</option>";
echo "</select></td></tr>";

foreach($detail_cart as $row)
echo "<tr><tD>$row->nama_barang</td><td>$row->qty</td></tr>"; // <- this code

the problem is i have 2 date in database. ex : 2012/10/9 and 2012/10/10
when i call it always give the same value for both date but in database i have different value, i know that when i call model the first value and read the second value, the model return the last value, help me to solve this, i dun wan use Session, thx

What exactly are you trying to do with the following piece of code?

$no = $hsl->notrans_users;
$query = $this->db->query("select b.nama_barang from barang b
where s.id_users = '$user_ids'")->result();

sorry, i cut that code and forgot to fix that, i already update my post, please take a look and help me

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.