![]() |
foreach need? - 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: foreach need? (/showthread.php?tid=27351) |
foreach need? - El Forum - 02-08-2010 [eluser]rich.a.coy[/eluser] Hi, If I know I'm only pulling and displaying 1 record do I still need the "foreach"? I played around trying to remove it but it did not seem to work. I know this works but it seems like extra code. Code: <?php if(isset($user)) : foreach($user as $me) : ?> Thanks. foreach need? - El Forum - 02-08-2010 [eluser]richzilla[/eluser] if in you're model, you're returning a Code: result() Code: row() foreach need? - El Forum - 02-08-2010 [eluser]rich.a.coy[/eluser] Ahh! In this case I know it's only one because I set a limit of one in the query and I'm looking up a unique user_id. Thanks! foreach need? - El Forum - 02-08-2010 [eluser]richthegeek[/eluser] result() returns an array you can use standard array indexing to get individual rows, eg $result[0]; foreach need? - El Forum - 02-08-2010 [eluser]John_Betong[/eluser] [quote author="rich.a.coy" date="1265664691"]Ahh! In this case I know it's only one because I set a limit of one in the query and I'm looking up a unique user_id. Thanks![/quote] From the User Manual: Code: row() |