SELECT a.uid, a.name_f, a.name_l, b.position FROM users a, room_members b WHERE a.uid = b.userid AND b.room_id=$room_id
I have the above query that selects the name, uid, profile pic and position of a certain user based on the room_id, and I want to return a while loop that assigns the following variables to any positions that returns in my query, dynamically.
$position1_name_f
$position1_name_l
$position1_uid
$position1_pic
$position2_name_f
$position2_name_l
$position2_uid
$position2_pic
So for example, if positions 4 and positions 8 are the only ones among the data returned, it would return the following variables and I would be able to use theses variables freely in my script.
$position4_name_f
$position4_name_l
$position4_uid
$position4_pic
$position8_name_f
$position8_name_l
$position8_uid
$position8_pic
There would be a maximum of 10 positions at the most. I desperately need those variables because I use them heavily with the layout of the site and there's no way for me to do a simple while loop echo; otherwise, everything would be a lot easier.
I tried using variable variables and I also tried deploy a counter but couldn't get either to work.
I started the following query and would really appreciate some help. Thanks
$room_members=mysql_query("SELECT a.uid, a.name_f, a.name_l, b.position FROM users a, room_members b WHERE a.uid = b.userid AND b.room_id=$room_id");
while($members_sql=mysql_fetch_array($room_members))
{
//Need some dynamic variables here...
}