Welcome Guest, Not a member yet? Register   Sign In
For displaying 2 dimenisional data in view PAge
#1

[eluser]mahins area[/eluser]
Hi


I have problem with displaying 2d array in view page .please help me.consider below code

Controller page
===============

a)I called a model class named Blogmodel

$this->load->model('Blogmodel', '', $config);

b) I called a function named et_last_ten_entries inside Blogmodel
$dbdata['details']=$this->Blogmodel->get_last_ten_entries();
using this

Model page
=========
I fetch data from table named emailids
$query = $this->db->get('emailids', 2);

return $query->result();


Cntroller page


When i use

print_r($dbdata);


Array ( [details] => Array ( [0] => stdClass Object ( [id] => 1 [title] => Quick Contact [mailid] => [email protected] [status] => A ) [1] => stdClass Object ( [id] => 2 [title] => Contact Us [mailid] => [email protected] [status] => A ) ) [heading] => My Real Heading )



i got lkike this


then i called my view page
with following fn

$this->load->view('blogview5', $dbdata);

View page(PBLM HERE)
=======================



foreach ($details as $row):
?>
<tr> &lt;?php
foreach ($row as $data):
?&gt;

<td>

&lt;?php echo $data; ?&gt;
</td>
&lt;?php endforeach;?&gt;
</tr>
&lt;?php endforeach;?&gt;


i just put this and i got following o/p


ID Title Mail ID STATUS
1 Quick Contact [email protected] A
2 Contact Us [email protected] A

But me just want mailid field.

So i used like this




foreach ($details as $row):
?&gt;
<tr> &lt;?php
foreach ($row as $data):
?&gt;

<td>

&lt;?php echo $data['mailid']; ?&gt;
</td>
&lt;?php endforeach;?&gt;
</tr>
&lt;?php endforeach;?&gt;




But no chance Data not coming .please help me
#2

[eluser]cideveloper[/eluser]
controller

Code:
$dbdata['heading']='My Real Heading';
$dbdata['details']=$this->Blogmodel->get_last_ten_entries();
$this->load->view('blogview5', $dbdata);

model

Code:
$query = $this->db->get('emailids', 2);
return $query->result();

view

Code:
<tr>  
        <td>
            Mail ID
        </td>
    </tr>
&lt;?php foreach ($details as $row):?&gt;
    <tr>  
        <td>
            &lt;?php echo $row->mailid; ?&gt;
        </td>
    </tr>
&lt;?php endforeach;?&gt;

Which will give you a table like this

Mail ID
--------
[email protected]
[email protected]
[email protected]
#3

[eluser]mahins area[/eluser]
thanks very much buddy.now things are working fine.Thanks again




Theme © iAndrew 2016 - Forum software by © MyBB