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 669059
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:06:35+00:00 2026-05-14T00:06:35+00:00

I am triig to fill options list. I have 2 tables USERS and STREAMS

  • 0

I am triig to fill options list. I have 2 tables USERS and STREAMS I vant to get all streams and get names of users assigned to that streams.

Users consists of username and id

Streams consists of id, userID, streamID

I try such code:

<?php           
        global $connection;
        $query = "SELECT * 
        FROM streams ";
        $streams_set = mysql_query($query, $connection);
        confirm_query($streams_set);    
    $streams_count = mysql_num_rows($streams_set);
    while ($row = mysql_fetch_array($streams_set)){
            $userid = $row['userID'];
                global $connection;
        $query2 = "SELECT email, username ";
        $query2 .= "FROM users ";
        $query2 .= "WHERE id = '{$userid}' ";

        $qs = mysql_query($query2, $connection);
        confirm_query($qs); 
        $found_user = mysql_fetch_array($qs);


 echo ' <option value="'.$row['streamID'].'">'.$row['userID'].$found_user.'</option> ';
}
    ?>

But it does not return USER names from DB=( So what shall I do to this code to see usernames as “options” text?

  • 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-05-14T00:06:36+00:00Added an answer on May 14, 2026 at 12:06 am

    You can do this with one query containing a JOIN on streams.userID=users.id

    $query = "
      SELECT
        s.streamId,
        s.userId,
        u.username
      FROM
        streams as s
      JOIN
        users as u
      ON
        s.userId=u.id
      ";
    $result = mysql_query($query, $connection);
    confirm_query($result);
    echo '<option value="">Debug: #rows=', mysql_num_rows($row), '"</option>';
    
    while ( false!==($row=mysql_fetch_array($result)) ) {
      sprintf('<option value="%s">id:%s name:%s</option>',
        $row['streamID'], // you probably should apply htmlspecialchars()
        $row['userID'], // on these two, too.
        htmlspecialchars($row['username'])
      );
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Tring to get C++ regex string capture to work. I have tried all four
Using This code: I am tring to fill the page with the data and
Im tring to show a list of articles on my site with a authour,
I am tring to use an ajax post to an action. GET requests work
I am tring to create a simple UserControl that contains a set of RadioButtons
I'm tring to learn C++ and I have a little problem. I have some
I am tring to make the google news sitemap by php script from mysql.(all
I am attempting to create a SVG Pie Graph that is 277 degrees. I
I'm tring to authenticate user to have access to page from extJS. I saw
I am tring to load razor views from a physical path that is outside

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.