Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
passing table results in data array to view not working
  • I am trying to store results in $data and pass it into the view // controller
    $data = DB::select('message')->from('comment')->as_assoc()->execute();
    $this->response->body = View::factory('add-idea-form', $data); // view
    <?php foreach($comments as $r): ?>
    <p><?=$r?></p>
    <?php endforeach; ?> I receive this error: http://cl.ly/B9ud (screenshot) If I do this within the controller, while commenting out the load view line, it displays the data appropriately foreach($data as $r):
    print '<p>'.$r.'</p>';
    endforeach; I am coming from CI and I am use to passing an array of data to the view and looping thru it. Any help is appreciated.
  • Change:
    DB::select('message')->from('comment')->as_assoc()->execute();
    

    to
    DB::select('message')->from('comment')->execute()->as_array();
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion