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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T16:45:20+00:00 2026-06-16T16:45:20+00:00

I continue to struggle with array! This is probably easy to answer. I’m retrieving

  • 0

I continue to struggle with array! This is probably easy to answer.

I’m retrieving a data set from MYSQL w/ PHP. I get an array that has the 1st row (ala the mysql_fetch_array). Typically I would just loop through this and get each value, but in this case I’m already in the middle of a loop and I need to find out if a particular value exists in the full data set (which will be more than 1 row).

I figured I could just loop through and put all the values into an array with something like:

$query = "SELECT MapId FROM Map Where GameId = $gl_game_id";
$result_set = mysql_query($query, $connection);
confirm_query($result_set);     
$map_set = array();
while($row = mysql_fetch_assoc($result_set)) {
    $map_set[] = $row;
}   

When I print_r this, I do in fact get the full data set (e.g. all rows of MapId from table Map).

So now, when I go to look in there and see if a value (that is coming out of this other loop) exists, it won’t find it.

So my code looks like:

if (in_array($i, $map_set)) {
    echo "yes, it's there baby!";       
}

But it doesn’t work. I tried hard coding the array, and that does in fact work. So there is simply something wrong with the way I’m constructing my array that this function doesn’t like it.

if (in_array($i, array(40,12,53,65))) {
    echo "yes, it's there baby!";       
}       

arrrg… I do hate being a noobie at this.

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

    Function mysql_fetch_assoc returned array.

    If you make print_r($map_set) then you will see that is 2-dimension array. Sure in_array not worked.

    Just replace $map_set[] = $row; by $map_set[] = $row["MapId"]; and then try again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So continue from this: Linking how PHP/HTML Please check the answer i accepted, and
It is like continue getting data from mysql using PHP and simultaneously stream out
Continue from this: Timed loop, 10 second between Which gave me a great answer
I continue to get this as I'm uploading my Android app information, screen shots,
I continue to get this error when attempting to compile a bit of code
Continue from this topic link text Hi guys. I am using codeigniter and want
I continue learning maven and try to understand why I get this error package
I continue with my newbie questions coming from PHP, there might be more than
Is it possible to continue or extend an existing schema with MySQL Workbench? This
I continue to get this error: Object '%s' cannot be renamed because the object

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.