having trouble looping through query results - 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: having trouble looping through query results (/showthread.php?tid=2989) |
having trouble looping through query results - El Forum - 09-03-2007 [eluser]jvittetoe[/eluser] Hello, in my application, once a user logs in they are directed to their dashboard controller... Code: <?php from here i am loading the model, and running the function qryOverview which queries the db for all user items associated with the user. here is the qry. Code: function qryOverview(){ having trouble looping through query results - El Forum - 09-03-2007 [eluser]coolfactor[/eluser] You weren't storing the returned query into the $query variable. You need something like this: Quote:$query = $this->userItems->qryOverview(); having trouble looping through query results - El Forum - 09-03-2007 [eluser]jvittetoe[/eluser] ah, thanks. now ive got my code looking like this... Code: function index(){ then in dspDashboard view file, Code: <?php this is resulting in a white blank page... having trouble looping through query results - El Forum - 09-03-2007 [eluser]Nillian[/eluser] Remove the $data['query'] in your view file and use simply $query. CI converts the array into individual variables for you to use in your view file having trouble looping through query results - El Forum - 09-03-2007 [eluser]jvittetoe[/eluser] so the variable $query will be automaically passsed to the view file? then would i run that loop in my view file? im getting a white page when i do that. having trouble looping through query results - El Forum - 09-03-2007 [eluser]coolfactor[/eluser] He means to do this: Code: foreach ($query->result_array() as $row){ having trouble looping through query results - El Forum - 09-03-2007 [eluser]jvittetoe[/eluser] yea, thats returning a blank white page :/ having trouble looping through query results - El Forum - 09-03-2007 [eluser]Nillian[/eluser] Try this thread: http://ellislab.com/forums/viewthread/59674/ Or this one: http://ellislab.com/forums/viewthread/56059/ They might not help, but I hope they do |