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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:07:51+00:00 2026-05-22T03:07:51+00:00

How can i create a search page with multiple criteria where at least a

  • 0

How can i create a search page with multiple criteria where at least a criteria should be checked.

Table Structure

  • ID [pk]
  • Name
  • Sex
  • Location

I want to create a search form where user will be able to search by name or by name,sex or by name,sex,location or any such combination among [name,sex,location]

How to design the query ?

Edit
i am not asking for checking atleast a single option has value [js validation], i am asking for the query !
I’ll use mysqli prepared statement !

  • 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-22T03:07:52+00:00Added an answer on May 22, 2026 at 3:07 am

    You can check to see if the post for a particular field is empty, if it’s not then append the corresponding WHERE clause to the query. Something in the form of the following:

    $mysqli = new mysqli(...);
    $sql = 'SELECT * FROM table WHERE ';
    $where = array();
    $values = array();
    $types = '';
    
    if (!empty($_POST['name'])) {
        $where[] = 'name = ?';
        $values[] = $_POST['name'];
        $types .= 's';
    }
    
    if (!empty($_POST['sex'])) {
        $where[] = 'sex = ?';
        $values[] = $_POST['sex'];
        $types .= 's';
    }
    ...
    $sql .= implode(' AND ',$where);
    $values = array_unshift($values, $types);
    
    $statement = $mysqli->prepare($sql);
    call_user_func_array(array($statement, 'bind_param'), $values);
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create search interface to search data from GAE datastore? Can i
I want to create a android search application that can be used to search
How Can i create a search for the CCK fields in Drupal? Currently using
I can't find anything anywhere(search engines, docs, here, etc) that shows how to create
I have a search page that is used in multiple places with multiple 'themes'
I am planning to create a custom search for my website and just want
I have a web site on Django. I want to create a search input
For my site, I've created a search page where users can search for the
Im trying to implement pagination using multiple searching criteria. Supposed I Have student table.
I want to create a functionality similar to what www.redfin.com has on their search

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.