Welcome Guest, Not a member yet? Register   Sign In
View that prints all the array $data['personas'] in a table html.
#1

Good morning and sorry for my english.
I have a very simple Controller, a very simple Model and I need the code of a simple View that prints all the array $data['personas'] in a html table.

The problem is:
I don't know the name of fields, I don't know how many fields has got the table, (or array)
And I need put the name of the fields in the first row of the html table...

Code of Controller:


Code:
class Controller_05_tabla_oracle extends CI_Controller {

  public function index()
  {
$this->load->helper('url');
$this->load->model('model_05_tabla_oracle');
$this->load->database();
$data['personas'] = $this->model_05_tabla_oracle->getPersonas_Ovh();
$this->load->view('view_05_tabla_oracle',$data);
  }
}

Code of Model:
Code:
class Model_05_tabla_oracle extends CI_Model{

function __construct()//model construct function
{
   parent::__construct();
   $this->ovh_db=$this->load->database('ovh',true);
}

public function getPersonas_Ovh()
{
$query = $this->ovh_db->query('select * from OVPRO.OVT_TRACKING_SESSION where rownum<=10');
return $query->result();
}
}


Code of View, (since now)

Code:
     <div class="page-header">
 
<?php foreach($personas as $p){ ?>
<Table border="1">
<tr><td><?php echo $p->USER_ID; ?></td></tr>
</Table>
<?php }//end foreach ?>
</br>
</br>
</br>
</br>
</br>
<pre><?php print_r($personas) ?></pre>

     </div>

This you can see:
[Image: 20170420035908.jpg]
And this is i need to see:
[Image: 20170420040000.jpg]
Thanks a lot for your atention.

Àngel Gimeno
Reply


Messages In This Thread
View that prints all the array $data['personas'] in a table html. - by Angel_Debat - 04-20-2017, 04:58 AM



Theme © iAndrew 2016 - Forum software by © MyBB