Welcome Guest, Not a member yet? Register   Sign In
Template parser class with database array
#3

[eluser]victorche[/eluser]
Try this:
Code:
function index() {
      $query = $this->db->query(SELECT * FROM guestbook);
      foreach ($query->result_array() as $row)
      {
           $senders[] = array(
             'sender' => $row['sender'],
            );
      }
      $data = array('content' => $senders);
      $this->parser->parse('template', $data);
}
And then in your template:
Code:
<html>
<body>
      <ul>
      {content}
            <li>{sender}</li>
      {/content}
      </ul>
&lt;/body&gt;
&lt;/html&gt;
As far as I know, if you have repeating blocks in your template, you should use {repeating_content} .... {/repeating_content}


Messages In This Thread
Template parser class with database array - by El Forum - 07-10-2010, 11:01 PM
Template parser class with database array - by El Forum - 07-11-2010, 12:31 AM
Template parser class with database array - by El Forum - 07-11-2010, 12:38 AM
Template parser class with database array - by El Forum - 07-11-2010, 12:56 AM
Template parser class with database array - by El Forum - 06-14-2011, 06:06 AM



Theme © iAndrew 2016 - Forum software by © MyBB