![]() |
feeling dumb - needing help - 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: feeling dumb - needing help (/showthread.php?tid=5516) |
feeling dumb - needing help - El Forum - 01-24-2008 [eluser]new_igniter[/eluser] ok, I am very new to this: this works Code: <?php this does not work Code: <?php echo $usersRow->name; ?> can anyone help me out with what I am not thinking about? I dont want to loop through anything, just print individual items in the view. feeling dumb - needing help - El Forum - 01-24-2008 [eluser]thurting[/eluser] It appears $usersRow is an array containing objects that have a property $name on them. Accessing the $name property of each of these objects is done successfully within the foreach loop. Attempting to access the $name of the $usersRow will fail because the array does not contain this property - it is the objects within it that do. Perhaps you should familiarize yourself with the underlying syntax of PHP. If you expect $usersRow to return one value, you can access it through $usersRow[0] and $name using $usersRow[0]->name. You should also check out http://ellislab.com/codeigniter/user-guide/database/results.html for information dealing with query results - which is what I think you are working with here. Docs available at php.net feeling dumb - needing help - El Forum - 01-24-2008 [eluser]wiredesignz[/eluser] Code: foreach($usersRow as $key => $row) feeling dumb - needing help - El Forum - 01-24-2008 [eluser]new_igniter[/eluser] Thanks so much, this really helps! feeling dumb - needing help - El Forum - 01-24-2008 [eluser]John_Betong[/eluser] [quote author="new_igniter" date="1201237184"]Thanks so much, this really helps![/quote] Try this: Code: echo '<pre>'; // purely cosmetic to add linefeed |