Duwi irwanto Duwi irwanto - 2 years ago 63
PHP Question

Displays the value but the result into an array

I am trying to retrieve data from a database by using multiple where when I call on Views of data actually appears letters array? What is wrong?


function produk() {
$sql = "SELECT penjualan * jumlah FROM toko
WHERE toko = 'ALFA' AND produk = 'susu'";

return $this->db->query($sql)->result();



public function index() {
$data=array('produk' =>$this->m_ff->produk(),
'isi' =>'home/v_ff'


<?php echo produk; ?>

Answer Source

make sure you column name are correct

Need to change your query to

  SELECT * FROM toko             
            WHERE toko = 'ALFA' AND produk = 'susu'

If you want to multiply two colunm Using Active record then use it as

 $this->db->select("`penjualan`*`jumlah` as multiply", FAlSE);// for multiplication of two column
   $ret = $query->row();// for single row
   return $ret->multiply;

And in View you get your data as

<?php echo $produk); ?>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download