Welcome Guest, Not a member yet? Register   Sign In
Why is it only returning 1
#5

[eluser]TWP Marketing[/eluser]
Code:
function members_area()
    {
        $username = $this->session->userdata('username');
        $queryG = $this->db->query("SELECT name FROM games WHERE author = '$username' ");
        
        if ($queryG->num_rows() > 0)
        {
            $data['games'] = array();
            foreach ($queryG->result_array() as $row)
            {
                $row['name'];// <-- this doesn`t do anything
            }
        }
        $data['games']=$row; //<-- this is outside the loop and will only receive the LAST $row data
        
        $this->load->view('logged_in_area', $data);
    }
Try this instead:
Code:
function members_area()
    {
        $username = $this->session->userdata('username');
        $queryG = $this->db->query("SELECT name FROM games WHERE author = '$username' ");
        
        if ($queryG->num_rows() > 0)
        {
            $data['games'] = array();
            $i = 1; // initialize counter
            foreach ($queryG->result_array() as $row)
            {
                $i++;
                $data['games'][$i] = $row;
            }
        }
        $this->load->view('logged_in_area', $data);
Now loop through the $games array in your view and it should contain more than one entry
[edit] ok your way is simpler than mine...


Messages In This Thread
Why is it only returning 1 - by El Forum - 04-18-2011, 03:34 PM
Why is it only returning 1 - by El Forum - 04-18-2011, 03:48 PM
Why is it only returning 1 - by El Forum - 04-18-2011, 03:50 PM
Why is it only returning 1 - by El Forum - 04-18-2011, 03:51 PM
Why is it only returning 1 - by El Forum - 04-18-2011, 03:56 PM



Theme © iAndrew 2016 - Forum software by © MyBB