Welcome Guest, Not a member yet? Register   Sign In
loading the results of a foreach
#3

[eluser]Unknown[/eluser]
Thank you PascalKriete for the quick response. That worked great. I just wasn't aware of the return. Thanks for the warm welcome to the CodeIgniter community.

For future reference:
MODEL
Code:
function retrieve_members ()
    {
        $query = $this->db->query('SELECT id, firstName, lastName, memberNum, email FROM member');
        return ($query->num_rows() >0) ? $query->result() : FALSE;
    }
CONTROLLER
Code:
function index()
    {    
        $this->load->database();
        $this->load->model('CMS_model');    
        $data['include'] = 'control_panel';
        $data['members'] =$this->CMS_model->retrieve_members();            
        $this->load->view('template', $data);
    }
VIEW
Code:
echo "<table>";
echo "<tr><td>First Name</td><td>Last Name</td><td>Membership Number</td><td>Email</td></tr>";
   foreach ($members as $row)
               {
          echo "<tr><td>";
          echo $row->firstName;
          echo "</td><td>";
          echo $row->lastName;
          echo "</td><td>";
          echo $row->memberNum;
          echo "</td><td>";
          echo $row->email;
          echo "</td></tr>";
               }
echo "</table>";


Messages In This Thread
loading the results of a foreach - by El Forum - 01-30-2009, 06:22 PM
loading the results of a foreach - by El Forum - 01-30-2009, 06:31 PM
loading the results of a foreach - by El Forum - 01-30-2009, 06:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB