CodeIgniter embedding database results in different html tags ( newbie here.. ) - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: CodeIgniter embedding database results in different html tags ( newbie here.. ) (/showthread.php?tid=6661) |
CodeIgniter embedding database results in different html tags ( newbie here.. ) - El Forum - 03-06-2008 [eluser]Unknown[/eluser] 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 - 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><?php $Real_name ?></h1> <h2><?php $Email ?></h2> <p><?php $Profile ?></p> <p><?php $position ?></p> <p><?php $SSS_number ?></p> How do I do that? CodeIgniter embedding database results in different html tags ( newbie here.. ) - El Forum - 03-06-2008 [eluser]Chris Newton[/eluser] Depending on how your $data is formatted, either access it as an object, or as an array $Real_name=$result->Real_name; OR $Real_name=$result['Real_name']; CodeIgniter embedding database results in different html tags ( newbie here.. ) - El Forum - 03-07-2008 [eluser]dark_lord[/eluser] In the Controller Code: $query['data'] = $this->db->get('mytable'); In the view: Pass you data from the query array using foreach. Code: foreach ($data->result() as $row) try this... Hope it works.. CodeIgniter embedding database results in different html tags ( newbie here.. ) - El Forum - 03-07-2008 [eluser]Avatar[/eluser] in your views if you use Code: <?php $blah?> Code: <?=$blah?> Code: <?php echo $blah; ?> Code: <?php foreach($blah->result() as $poop)?> |