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

  • Home
  • SEARCH
  • 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 8613083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:47:06+00:00 2026-06-12T04:47:06+00:00

I have a private message system and I have this function that returns the

  • 0

I have a private message system and I have this function that returns the IDs of all the users in the conversation (except the sender):

function findOtherUsersInConversation($conversation_id) {
    $sender = findMessageSenderId($conversation_id);
    $query  = mysql_query("SELECT user_id FROM message_partecipant WHERE conversation_id =   '$conversation_id' AND user_id !=$sender");
    while ($row = mysql_fetch_array($query)) {
        $user_id = $row['user_id'];
        print_r($user_id);
    }
}

print_r return the Ids (for instance id100 and id 101)like this:

100101//which is not what i'm trying to do

I have another function that find the username in the database so for each user id I would like to get their usernames in this format:

echo usernameFromId($user_id)// this should echo out all the username like this (user a, user b, user c)

I think I have to do a foreach loop but I can’t think how.

  • 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-12T04:47:08+00:00Added an answer on June 12, 2026 at 4:47 am

    Try this:

    function findOtherUsersInConversation($conversation_id){
        $sender = findMessageSenderId($conversation_id);
        $query =  mysql_query("SELECT user_id FROM message_partecipant WHERE conversation_id =   '$conversation_id' AND user_id !=$sender");
        $users = array();
        while ($row = mysql_fetch_array($query)) {
            $users[] = usernameFromId($row['user_id']); // fetch user name and add it to array
        }
        return implode(', ', $users); // return a string separated by commas
    }
    
    findOtherUsersInConversation(10); // conversation id 10
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a private function like this in my controller. private UserDetails GetUserDetails(int userid)
I added FileSystemWatcher in Form1_Load like this: Private Sub Form1_Load(ByVal sender As System.Object, ByVal
I have a function that redirects to a countdown while our system is offline,
I probably should have just put all this in one question, sorry for that
In my messages_controller I have the following private method: def find_message_or_404(slug) message = user.messages.find_by_slug(slug)
I have a WCF service that posts messages to a private, non-transactional MSMQ queue.
Here's the c# code that I have: private double get806Fees (Loan loan) { Loan.Fee.Items
Why can NHibernate create a proxy for classes with properties that have private setters
I have a private project, and i want it hosted on google code. this
I have a private class variable that holds a collection of order items: Private

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.