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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:13:59+00:00 2026-06-07T16:13:59+00:00

I am programming a chat room on my site but I am really new

  • 0

I am programming a chat room on my site but I am really new to php. I want users to be able to chat with the users that played in the same teams of a game (knowing that users can have participated together to differents team) and who work in the same area.

Assume there are three tables : the account user’s table, the area’s t able, games’table

I have a function that returns my query that looks like

function myfunction($userid){

$games_user=mysql_query('select theme from games where games.userid="'.$userid.'"');  
$games_theme = mysql_fetch_array($games_user);

$sql = ("select  userid, username, area.userid 

    from account 
        left join area
            on account.userid = area.userid    

        left join games
            on account.userid = games.userid

    where account.userid <> '".mysql_real_escape_string($userid)."' and '".(in_array(games.theme,$games_theme))."' and area.userid=1 
 );
 return $sql;
}

Reformatted:

$sql = "
SELECT userid, username, area.userid 
FROM account 
LEFT JOIN area ON account.userid = area.userid    
LEFT JOIN games ON account.userid = games.userid
WHERE account.userid <> '".mysql_real_escape_string($userid)."'
  AND '".(in_array(games.theme,$games_theme))."'
  AND area.userid = 1 
";

But it really doesn’t work, I think I have syntax problems.
I don’t really understand how in_array is indexed, and I don’t know how to do in a simpler way that query

Can anybody help ?

  • 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-07T16:14:00+00:00Added an answer on June 7, 2026 at 4:14 pm

    I’m still not entirely sure what you are doing, but I think this is what you want; you can do this in a single query:

    <?php
    function myfunction($userid){
        $id = mysql_real_escape_string($userid);
        $sql = "SELECT  userid, username, area.userid 
            FROM account 
                LEFT JOIN area
                    ON account.userid = area.userid    
                LEFT JOIN games
                    ON account.userid = games.userid
            WHERE account.userid<>'$id' AND area.userid=1
                AND games.theme IN (SELECT theme FROM games WHERE games.userid='$id')
        ";
        return $sql;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a chat application(Socket Programming) , for that consider I have 2 separate
I am creating a chat application using java sockets programming. I want to launch
Programming language: Java Ok, so I want to have a BufferedImage that keeps rotating
I am new to UDP/networking programming, and I am trying to create a chat
I am new to iOS programming, i read the view controller programming guide but
I want to build a simple chat session between two users, not more. I
I'm new to Android Java programming. I've created a simple chat app. Things are
Programming language books usually explain that value types are created on the stack, and
I'm fairly new to HTML, PHP, CSS and Javascript. I do have a bit
I'm writing a TCP chat server ( programming language does not mather ). It's

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.