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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T08:18:09+00:00 2026-06-16T08:18:09+00:00

I have an array $user = array([0]=>1 [1]=>2 [2]=>3) which contains id’s of certain

  • 0

I have an array

$user = array([0]=>1 [1]=>2 [2]=>3)

which contains id’s of certain users.
I need to get the countries of these users from database.

foreach($userid as $user){
    $this->db->select('country');
    $this->db->where('user_id',$user);
    $this->db->from('company');
    $usercountry = $this->db->get();
    $count = $usercountry->row();
    $country = $count->country;
    }

Suppose user1 has country ES, user2 has IN, user3 has US, user4 has UK. then if array contains 1,2,3. Then i need to get the countries ES,IN,US.

  • 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-16T08:18:10+00:00Added an answer on June 16, 2026 at 8:18 am

    This is the way normal query for this kind of array’s

    public function get_countries($user)
    {
     $query = "select country from company where user_id IN($user)";
     $result = $this->db->query($query);
     if($res->num_rows()>0){
            return $res->result("array");
        }
        return array();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have Javascript array which contains User object. I have created this array from
I have a session array [cart] of which contains user id numbers. I am
I have an ASP.NET MVC view which contains checkboxes for user-defined categories. <td><% foreach
I have an array which contains 2 types of items (lets call them type
I have a form which contains a series of fields like: <input type=text name=User[123]
I have a table of Users (tblUsers) which contains details of University staff. I
I have an NSArray which contains 10 objects from index 0 - 9. Each
I have a php page which extracts data from a dbms which contains email
I have a array which contains values like this See below for script sample
I have an array named $mark_ary which contains this: Array ( [0] => 61

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.