Welcome Guest, Not a member yet? Register   Sign In
Selecting one value from database?
#3

[eluser]xwero[/eluser]
[quote author="fancms" date="1193079984"]

Code:
$this->db->select('value'); #Because I need the value
$this->db->where('variable', 'siteoverview'); #Because I need the variable column entitled siteoverview
$grab_cache = $this->db->get("settings"); #From the settings table

[/quote]

You are on the right path but you have to go more specific

Code:
$this->db->select('value'); #Because I need the value
$this->db->where('variable', 'siteoverview'); #Because I need the variable column entitled siteoverview
$query = $this->db->get("settings"); #From the settings table
$row = $query->row; // get the row
echo $row->value

If you want to put it in a function

Code:
function scalar($table,$field,$where)
   $this->db->select($field); #Because I need the value
   $this->db->where($where); #Because I need the variable column    entitled siteoverview
   $query = $this->db->get($table); #From the settings table
   $row = $query->row_array(); // get the row
   return $row[$field]; // return the value
}


Messages In This Thread
Selecting one value from database? - by El Forum - 10-22-2007, 08:06 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:18 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:25 AM
Selecting one value from database? - by El Forum - 10-22-2007, 08:46 AM
Selecting one value from database? - by El Forum - 10-22-2007, 09:15 AM
Selecting one value from database? - by El Forum - 10-22-2007, 09:27 AM
Selecting one value from database? - by El Forum - 10-22-2007, 10:33 AM



Theme © iAndrew 2016 - Forum software by © MyBB