Welcome Guest, Not a member yet? Register   Sign In
how to display the data's from the database?
#1

[eluser]jeanel16[/eluser]
I want to display all my data from the database into my website.

here is my code in my model:
$this->db->select('*')->from('msgdb');
$query = $this->db->get();
return $query->result();

and onto my controller:

$this->load->model('inboxmsgmodel');
$data['inbox'] = $this->inboxmsgmodel->inboxview();
$this->load->view('inboxmsgview', $data);

and in my view:
i dont know what to put xD help pls
#2

[eluser]kanjimaster[/eluser]
In your model (inboxmsgmodel) you could just put ...
Code:
public function get_inbox() {
  return $this->db->get('msgdb')->result();
}
(this assumes that 'msgdb' is a table within your database)

In your controller ...
Code:
$this->load->model(‘inboxmsgmodel’);
$data[‘inbox’] = $this->inboxmsgmodel->get_inbox();
$this->load->view(‘inboxmsgview’, $data);
(very similar to what you have now)

And in your view (assuming that your database table has columns called say 'from', 'subject' and 'content') ...
Code:
<?php
  foreach ($inbox as $msg) :
    echo $msg->from;
    echo $msg->subject;
    echo $msg->content;
  endforeach;
?>

You may also want to take a look at Codeigniter's HTML table class as a quick and easy way to output a query's results as a table.
#3

[eluser]jeanel16[/eluser]
yap all you have assumed was all correct thanks ^___ _^




Theme © iAndrew 2016 - Forum software by © MyBB