Listing DB entries?

#1
[eluser]Unknown[/eluser]
Hi everybody,

I started using CI and I'm having a problem with database entry listing.
I list the entries fine, but I need to assign some template to them.

For instance

Code:
<div class="class">$title</div>
<div class="class">$date</div>

Function for DB listing is as follows:
Code:
$query = $this->db->get('posts', 10);
        foreach($query->result() as $row) {
  $data[] = $row;
  }
  return $data;

Now, if I echo the template in foreach loop, I'll most likely get some kind of error, since I noticed CI is really strict about output, but I have no idea, even if that works, how to send it to the view.

#2
[eluser]Unknown[/eluser]
Solution: Instead of outputting an array of data, output just one variable that contains the design.
Although it solves a template problem, it doesn't solve a problem of outputting only one result.

So, the question is: How to output more results?

#3
[eluser]sajid19991[/eluser]
[quote author="stefo" date="1356810398"]Solution: Instead of outputting an array of data, output just one variable that contains the design.
Although it solves a template problem, it doesn't solve a problem of outputting only one result.

So, the question is: How to output more results?[/quote]

Hi, if you are new i would suggest you to output the result using codeigniters template parser library, which will solve most of your problems. please refer to CI Template Parser Guide ...i always use parser for better results with design..its not advanced parser but advance enough to get rid of some headaches...


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.