Welcome Guest, Not a member yet? Register   Sign In
Get a single value from a a database ?
#1

[eluser]chefnelone[/eluser]
Hello I have this funcion in a model.

I retrieve one value (product_name) for a table (products).
It works fine but... as you can see I'm using a foreaech() to echo the result.

Since I just get 1 result I don't want to use the foreach() statement.

Question: How do I echo the result NOT using foreach()

Code:
function get_product(){
  $this->db->where("product_id", "10");
  $this->db->limit(1);
  $query = $this->db->get('products');

  foreach ($query->result() as $row)
    {
     echo $row->product_name;
    }    
}

Thanks


Messages In This Thread
Get a single value from a a database ? - by El Forum - 02-01-2010, 07:44 AM
Get a single value from a a database ? - by El Forum - 02-01-2010, 07:49 AM



Theme © iAndrew 2016 - Forum software by © MyBB