itsureboy Posted July 5, 2009 Share Posted July 5, 2009 I'm new to PHP and everything, so I was wondering. Is it possible to assign a WHILE loop to a variable. I am trying this, just in case it is even possible. $query = while($row = mysql_fetch_array($result)){ echo ' OR commenterid = '.$row['friendid'].' '; }; And get the error: Parse error: syntax error, unexpected T_WHILE Thanks ahead, Chris Link to comment https://forums.phpfreaks.com/topic/164802-solved-can-you-assign-a-while-loop-to-a-variable-if-so-how/ Share on other sites More sharing options...
trq Posted July 5, 2009 Share Posted July 5, 2009 while() doesn't return anything, what do you expect? Maybe you want something more like?.... $query = ''; while($row = mysql_fetch_array($result)) { $query .= ' OR commenterid = ' . $row['friendid']; } Link to comment https://forums.phpfreaks.com/topic/164802-solved-can-you-assign-a-while-loop-to-a-variable-if-so-how/#findComment-869053 Share on other sites More sharing options...
itsureboy Posted July 5, 2009 Author Share Posted July 5, 2009 It worked! You don't know how thankful I am. =) THANK YOU!!!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/164802-solved-can-you-assign-a-while-loop-to-a-variable-if-so-how/#findComment-869059 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.