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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:17:48+00:00 2026-05-23T12:17:48+00:00

I have a script that searches for users in the db. I have two

  • 0

I have a script that searches for users in the db. I have two input fields so that I can search for e.g. city and house number. What I want is that if I type e.g. London in the city field and the number 20 it returns the record with London AND 20 in it. I’m not quite sure how to achieve this. I did enough research on Google but still didn’t find the answer.

Here is my code:

if($_GET['search'] != ''){
$result = mysql_query("SELECT * FROM klant WHERE klant_id LIKE '%" .$search."%' OR             voornaam LIKE '%" .$search."%' OR achternaam LIKE '%" .$search."%' OR email LIKE '%"        .$search."%' OR plaats LIKE '%" .$search."%' OR bedrijfsnaam LIKE '%" .$search."%'ORDER BY       klant_id DESC");


$result2 = mysql_query("SELECT * FROM klant WHERE klant_id LIKE '%" .$search2."%' OR voornaam   LIKE '%" .$search2."%' OR achternaam LIKE '%" .$search2."%' OR email LIKE '%" .$search2."%' OR   plaats LIKE '%" .$search2."%' OR bedrijfsnaam LIKE '%" .$search2."%'ORDER BY klant_id DESC");
$i = 0;

}

What I need is something that will give the proper $result where those two search values ($search and $search2) are combined. Thus allowing me to search much easier.

Hope that i phrased my question well enough for you to understand me and I hope that you can help me!

  • 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-23T12:17:49+00:00Added an answer on May 23, 2026 at 12:17 pm

    Please try with the following logic –

    if($_GET['search'] != ''){
    $search = $_GET['search'];
    $where[] = "( klant_id LIKE '%" .$search."%' OR  voornaam LIKE '%" .$search."%' OR achternaam LIKE '%" .$search."%' OR email LIKE '%"        .$search."%' OR plaats LIKE '%" .$search."%' OR bedrijfsnaam LIKE '%" .$search."%' ) ";
    }
    if($_GET['search2'] != ''){
    $search2 = $_GET['search2'];
    $where[] = " ( klant_id LIKE '%" .$search2."%' OR voornaam   LIKE '%" .$search2."%' OR achternaam LIKE '%" .$search2."%' OR email LIKE '%" .$search2."%' OR   plaats LIKE '%" .$search2."%' OR bedrijfsnaam LIKE '%" .$search2."%') ";
    }
    $query_where = (is_array($where))?" WHERE ".implode(" AND ", $where):""; 
    $result = mysql_query("SELECT * FROM klant ".$query_where." ORDER BY klant_id DESC");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple PHP script with a form that has two select fields,
I have a PHP keyword search script that searches a MySQL database and then
At the minute I have a page with an AJAX script that searches a
I have a script that updates a CSS file based upon some user input
I have a jQuery search script that uses tabs for the user to define
I have a jQuery search script that uses tabs for the user to define
I have a form with a table that has two input boxes, a select
I have a jQuery search script that uses tabs for the user to define
I have a jQuery search script that uses tabs for the user to define
I have a Google Instant style jQuery search script that queries a PHP file

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.