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

The Archive Base Latest Questions

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

I am trying to query my database and create values for later use in

  • 0

I am trying to query my database and create values for later use in another function. My first function (get_users()) should query the requests database and find all users listed for the specific global_id – there will always be a maximum of 4 users for this query. Then I want to use a second function (get_results()) and insert the values that were retrieved from the first function (get_users()) into the second function. In other words, i need to put users1,2,3,4 into get_results($user1, $user2, $user3, $user4) in the second function.

Hoping someone can help! Here are my functions:

        function get_users($global_id)
    {
        $result = mysql_query("SELECT user_purchased FROM requests WHERE global_id = '$global_id'");
        $row = mysql_fetch_row($result);
        $user1 = $row[0];
        $user2 = $row[0];
        $user3 = $row[0];
        $user4 = $row[0];
    }
    function get_results($user1, $user2, $user3, $user4)
    {
        $result = mysql_query("SELECT * FROM results WHERE username != '$user1'
        AND username != '$user2'
        AND username != '$user3'
        AND username != '$user4'
        ORDER BY distance");
        ...more stuff to do here with the query
    }

Thanks

  • 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-02T22:51:49+00:00Added an answer on June 2, 2026 at 10:51 pm

    Call the second function inside the first one:

    function get_users($global_id)
        {
            $result = mysql_query("SELECT user_purchased FROM requests WHERE global_id = '$global_id'");
    $count = 0;        
    while($row = mysql_fetch_array($result))
            {
            $user[$count] = $row;
            $count++;
            }
        get_results($user[0],$user[1],$user[2],$user[3]);
        }
    
        function get_results($user1, $user2, $user3, $user4)
        {
            $result = mysql_query("SELECT * FROM results WHERE username != '$user1'
            AND username != '$user2'
            AND username != '$user3'
            AND username != '$user4'
            ORDER BY distance");
            ...more stuff to do here with the query
        }
    

    You can even simplify the get_results function to have one variable as an array instead of 4 varialbles

    function get_results($users)
            {
                $result = mysql_query("SELECT * FROM results WHERE username != '".$users[0]."'
                AND username != '".$users[1]."'
                AND username != '".$users[2]."'
                AND username != '".$users[3]."'
                ORDER BY distance");
                ...more stuff to do here with the query
            }
    

    And you should call it like this in the first function

    get_results($users);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to create a select command to query the database I have and
i am trying to create a database value from the values submited, and inserting
I'm trying to import a table in my database executing this query : CREATE
I am trying to reconstruct a database query I created for MySQL in Microsoft
I'm trying to create a faster query, right now i have large databases. My
I'm trying to query a database view that's not located on the same server
I'm trying to query a database from the Application_BeginRequest in my Global.asax file to
I'm trying to query a MySQL database using an array but I'm having trouble!
I am trying to query SQL Server database from C# I have class Class_A
What I'm trying to do is the following:- Query my database to show only

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.