Welcome Guest, Not a member yet? Register   Sign In
feeling dumb - needing help
#1

[eluser]new_igniter[/eluser]
ok, I am very new to this:

this works
Code:
<?php
    foreach($usersRow as $row)
    {
        echo $row->name;
    }
?>

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.
#2

[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-gui...sults.html for information dealing with query results - which is what I think you are working with here.

Docs available at php.net
#3

[eluser]wiredesignz[/eluser]
Code:
foreach($usersRow as $key => $row)
{
    echo $row->name;
}
#4

[eluser]new_igniter[/eluser]
Thanks so much, this really helps!
#5

[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
      echo print_r($usersRow) ;
   echo '</pre>';




Theme © iAndrew 2016 - Forum software by © MyBB