[eluser]jedd[/eluser]
Hi Hitesh Chavda and welcome to the CI forums.
You might also want to look at
$this->db->row_array() (In the 'generating queries' section of the Database Class in the manual). Arrays are sometimes easier to get your head around than objects, and in this instance it looks like you want to extract a single column from a single row - so an array is a less expensive way of getting that data.
[quote author="Hitesh Chavda" date="1250528136"]
2) And Suppose I don't know the field_name and I want to print the first result from the query, How can I do this. Please Help..
[/quote]
Hmm .. not sure what you mean. You've done a select with $field_name - how would you select on something you don't know the name of?
If you mean that $field_name is a variable, then using row_array() you could then do this (though it's not substantively different from your current code, so I suspect I've misunderstood your intention)
Code:
$foo = $this->db->row_array();
return $foo[$field_name];