For displaying 2 dimenisional data in view PAge |
[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> <?php foreach ($row as $data): ?> <td> <?php echo $data; ?> </td> <?php endforeach;?> </tr> <?php endforeach;?> 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): ?> <tr> <?php foreach ($row as $data): ?> <td> <?php echo $data['mailid']; ?> </td> <?php endforeach;?> </tr> <?php endforeach;?> But no chance Data not coming .please help me
[eluser]cideveloper[/eluser]
controller Code: $dbdata['heading']='My Real Heading'; model Code: $query = $this->db->get('emailids', 2); view Code: <tr> Which will give you a table like this Mail ID -------- [email protected] [email protected] [email protected]
[eluser]mahins area[/eluser]
thanks very much buddy.now things are working fine.Thanks again |
Welcome Guest, Not a member yet? Register Sign In |