lil lil - 2 years ago 66
PHP Question

How to extract field values from query result

I have problem in extracting data from query result. I have the following method in my model that returns a result of many rows

function method(){

$query = $this->db->get();

return $query->result();

from my controller I call the above function like this

$data['returned_records']= $this->model_name->method();

and now I want to display returned_records in table format in a view. How do I go about that?

Answer Source

To display the output in view in tablur form The code would be something like this:

<table border="1">  
                <td>Heading 1</td>  
                <td>Heading 2</td>  
              // add more according to requirement
             foreach ($returned_records->result() as $row)  
                <td><?php echo $row->Column_name;?></td>  
                <td><?php echo $row->Column_name;?></td>
               // add more according to requirement  
             <?php }  
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download