Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7801153
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:51:32+00:00 2026-06-02T00:51:32+00:00

SELECT a.uid, a.name_f, a.name_l, b.position FROM users a, room_members b WHERE a.uid = b.userid

  • 0
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...
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T00:51:33+00:00Added an answer on June 2, 2026 at 12:51 am

    You’re doing it wrong!

    That’s what arrays are for:

    $result = array();
    
    $result[1] = array('name_f' => 'data',
                       'name_l' => 'data',
                       etc,
                       );
    

    From your comment:

    But how would I go about checking whether a position was set or returns back empty? I basically need if (isset(position_1)) {show position_1_name_f}

    if (isset($result[1])) {
        echo $result[1]['name_f'];
    }
    

    So what you can do is the following:

    $members = array();
    
    $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_assoc($room_members)) {
        $members[] = $members_sql;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following Query: SELECT a.name_f, a.uid, a.name_l, a.profile_pic, b.position FROM users a
I have the following tables users: uid, name_f, name_l... group_data: id, group_id, admin, invitedusers,
I have a query that select the top 5 of the UID that most
I have this FQL query select uid, name, website from user where website !=
FB.api( { method: 'fql.query', query: 'select uid,name from user where uid in (select uid2
I have a query that grabs information from four different tables, and joins them
These two queries work: SELECT u.id, u.email, COUNT(*) as Current FROM users u, rounds
select @result=@input.query('*') for xml raw,type Above statement will generate following alert: Msg 6819, Level
I have the below SQL query: SELECT g.name AS gname, COUNT(u.id) AS noMembers, f.name
What I'm trying is to get all users that don't have a value set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.