• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
A simple query

#1
[eluser]sudinem[/eluser]
I got stuck on how to show the field name and value at once

for example:

$result=$this->description_model->get_desc_by_id('1');

I can get the values by:
foreach($result->row as $values)
{
echo $values;
}

how to get the field name so as to display field name as well as their respective values.

Sudinem

#2
[eluser]danmontgomery[/eluser]
No way of knowing what get_desc_by_id() returns, but if it were a mysql result with a single row:

Code:
$query = $this->db->where('id', $id)->get('some_table');
foreach($query->row() as $field => $value) {
    echo $field . ': ' . $value . '<br/>';
}

http://ellislab.com/codeigniter/user-gui...sults.html
http://php.net/manual/en/control-structures.foreach.php

#3
[eluser]sudinem[/eluser]
Thanx for ur help..It works !!!!!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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