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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:49:42+00:00 2026-05-30T04:49:42+00:00

Is it possible to make a query with data from an array in PHP

  • 0

Is it possible to make a query with data from an array in PHP on multiple columns in a database?

Example:

SELECT * FROM rooms WHERE Facility1,Facility2,Facility3,Facility4,Facility5,Facility6,Facility7,Facility8,Facility9 = ' { Array Values Here } ' 

I have list of checkbox values stored in an array and I only want to select these. If it is not possible, how else can I run a query to select these?

  • 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-05-30T04:49:44+00:00Added an answer on May 30, 2026 at 4:49 am

    Sure it is possible to query multiple fields:

    WHERE Facility1 = 'value1' AND Facility2 = 'value2' ...
    

    That’s standard SQL, you find it documented in the mysql manual as well:

    • MySQL Select Syntax
    • MySQL Expressions

    For your specific problem (checkbox array values) it heavily depends. You need to map the checkbox array values to the fields in the mysql database to create an SQL statement that makes sense.

    As you have not given any information next to that it’s an array, there is not much to give as an example but that you map these array values to database columns.

    $columns = array('Facility1' => 'checkboxname1', 'Facility2' => 'checkboxname2');
    $query = 'SELECT * FROM rooms WHERE ';
    $queryWhereAnd = array();
    foreach($columns as $column => $name)
    {
        $queryWhereAnd[] = sprintf('%s = \'%s\'', $column, mysql_real_escape_string($_POST[$name]));
    }
    $query .= implode(' AND ', $queryWhereAnd ) . ';';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible in SubSonic to make a query like this SELECT * FROM
I was wondering today if it was possible to transfer data from one database
I'm pulling data from a database and one of the tables contain two columns
I have multiple select statements from different tables on the same database. I was
Is it possible to make a simple query to count how many records I
Possible Duplicate: Make iPhone app paid version replace free version on install from app
Is it possible to make a POST request from Ruby with open-uri?
I'm using the Repeater control on my site to display data from the database.
I am executing a query that gets some data from a remote server. It
In postgresql, I need to insert data to, say table B from sql query

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.