访问mysql_fetch_object返回的每一行时如何进行循环?

I want to be able to do something like this:

function x(){
   ....blablabla.. 
return mysql_fetch_object($result);
}
$entries = x();

foreach($entries as $entry){
echo "$entry->member_1";

}

when i did this, it gave me 0 result and printed nothing on the screen. I have seen the while-loop solutions too many times already, I want to know if there is a way to do this using for loop? thx

You either want:

function x(){
   ....blablabla..
   $return = array();
   while($object = mysql_fetch_object($result)) $return[] = $object;
   return $return;
}

$entries = x();
foreach($entries as $entry){
   echo $entry->member_1;
}

Or:

function x(){
   ....blablabla.. 
   return mysql_fetch_object($result);
}
$entries = x();

foreach(get_object_vars($entries) as $entry){
   echo $entry->member_1;
}

I suspect the first.

Like this?

$result = mysql_query(..);
for (;$row = mysql_fetch_object($result);) {
    echo $row->member_1;
}