CodeIgniter Forums
Parse error: syntax error, unexpected $end caused by foreach in view - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Parse error: syntax error, unexpected $end caused by foreach in view (/showthread.php?tid=52045)

Pages: 1 2


Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]InsiteFX[/eluser]
Create a new method and pass in the users id and fetch the data like the one above.

Code:
function get_user($id = '')
   {
    $this->db->where('id', $id);  // get users record
    $q = $this->db->get('membership');   // this would be changed to your users table name

    if($q->num_rows() > 0) {
      // return a single db row array $row['name'];
      return $q->row_array();
      // return a single db object $row->name;
      // return $q->row;      
     }
     return FALSE;
  }
}

Or if your seesion already contains the users id pass that in to the new method.

I wish you were home so that we could work together like before lol.

You need to show your profile table so that we can see what needs to be done...



Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]swgj19[/eluser]
I was thinking something with the id. I know how to do this in procedural php, but am now learning all this stuff with the mvc. I think from here now it is smooth sailing.

Ray, I am working on a cool website. It will take some time, but I am working on it as I have the time. I will be on skype tonight after midnight my time if you want to chat about it. I will probably get off work at 12:40am tonight. When I go to the computer lab, I will have a good internet connection. I will bring my headset and also be able to do Team Viewer 7.

Thanks for the help again. Once I get good enough, I can start helping you with building your tutorials for your site. I can at least do the basic tutorials I think..


Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]InsiteFX[/eluser]
Add a user_id to your profile table and make it a key

Then you can grab the users profile by their user id.

So when you create the users profile assign the users id to the profile users id.



Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]InsiteFX[/eluser]
I forget now what was our time difference 2 hours I think right?

But I should be on tonight.



Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]swgj19[/eluser]
Yeah, you are two hours ahead of my time.


Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]InsiteFX[/eluser]
Na, the grandson went home today so I have my computer back.



Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]swgj19[/eluser]
Nice. You might have to spend a few hours uninstalling games or software. lol


Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-28-2012

[eluser]InsiteFX[/eluser]
Na, his games are alright no problems he only has two on here.

Love my new SSD hard drive thing is fasssst!



Parse error: syntax error, unexpected $end caused by foreach in view - El Forum - 05-30-2012

[eluser]swgj19[/eluser]
See ya later..