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

#1
[eluser]C_Line[/eluser]
i wan to print value from database

here's my code

Code:
controller
function ambil_dataUser($value)
{
$this->load->model("Query_barang",'',TRUE);
$data['query'] = $this->Query_barang->ambil_data_users($value);
$data['detail_cart'] = $this->Query_barang->detail_shopcart($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;
}

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,
b.berat,s.qty
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;
}

view
<?php
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>";
}else{
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
}
?&gt;

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

#2
[eluser]mr_prasanna[/eluser]
What exactly are you trying to do with the following piece of code?

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

#3
[eluser]C_Line[/eluser]
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  


Users browsing this thread:
1 Guest(s)


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