Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter embedding database results in different html tags ( newbie here.. )

I am a Codeigniter newbie, and here is my question I know that you get data from your database in an array form. But how do I seperate Data into seperate pieces so I can apply different html tags and CSS to different categories. For ex.

In my Database I have 6 Categories which are:

- Employee_id
- Real_name
- Email
- Profile
- Position
- SSS_number

Ok, so I do a foreach($data as $result) to get the result. In my page I wanna do this.

<h1>&lt;?php $Real_name ?&gt;</h1>
<h2>&lt;?php $Email ?&gt;</h2>
<p>&lt;?php $Profile ?&gt;</p>
<p>&lt;?php $position ?&gt;</p>
<p>&lt;?php $SSS_number ?&gt;</p>

How do I do that?

[eluser]Chris Newton[/eluser]
Depending on how your $data is formatted, either access it as an object, or as an array




In the Controller
$query['data'] = $this->db->get('mytable');
$this->load->view('show_data', $query);

In the view: Pass you data from the query array using foreach.

foreach ($data->result() as $row)
    echo $row->id;
    echo $row->username;

try this... Smile Hope it works..

in your views if you use
&lt;?php $blah?&gt;
wont work, have to use either:
which does echo with semicolon or do this:
&lt;?php echo $blah; ?&gt;
&lt;?php foreach($blah->result() as $poop)?&gt;
&lt;?php endforeach;?&gt;
hope this helps

Theme © iAndrew 2016 - Forum software by © MyBB