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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:41:37+00:00 2026-05-17T15:41:37+00:00

I am working in PHP and Mysql Combo I need to search the results

  • 0

I am working in PHP and Mysql Combo

I need to search the results from DB and store in a hidden field , on change of the value user inserts in a text box.

How can I do this Using Ajax?

  • 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-17T15:41:38+00:00Added an answer on May 17, 2026 at 3:41 pm

    You will need a few things:

    • Your main page.
    • A php file which processes the given input (the search string) and outputs only the value you want to store in the hidden field (returnsearchresults.php in the example below).
    • Some javascript to make the ajax work.

    I’d recommend using jQuery for the ajax though you could always roll your own if you’re a masochist.

    On your main page you will need something like this:

    $("#ID_OF_SEARCH_BOX_GOES_HERE").keydown(function(event) {
        search_string = $("#ID_OF_SEARCH_BOX_GOES_HERE").val();
        $("#ID_OF_HIDDEN_FIELD_GOES_HERE").load("returnsearchresults.php?q="+search_string);
    });
    

    Edit: Here’s an idea of what returnsearchresults.php should look like:

    <?php
         $search_string = $_GET['q'];
         // ADD SOME CHECKS IN HERE TO PREVENT SQL INJECTION OR WHATEVER
         $SQL = "SELECT 
                     whatever_you_need, 
                 FROM 
                     your_database 
                 WHERE 
                     the_column 
                 LIKE 
                     '%$q%'";
         $result = mysql_query($sql);
         while ($row = mysql_fetch_array($result))
         {
             echo $row[0], ', '; // obviously this line depends on how 
                                 // you need to format your hidden field.
         }
    ?>
    

    Note: I haven’t included code to open/close the database connection or to verify that $_GET[‘q’] isn’t malicious. I’ll leave that up to you!

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

Sidebar

Related Questions

I am working on a PHP/MySQL based ecommerce engine, and need it to be
HI GEEKS I am working in PHP and Mysql. I have an array from
I'm working on a PHP/MySQL rating system right now. For the user to be
Today im working with PHP and MySQL and i store Dates in an Timestamp
I am working on a PHP/MySQL messaging application in which a user can see
I'm working on a multi critera search on php/mysql, this search has 5 entries:
I am working on a PHP-Mysql based website which has some large lists to
I am working on a php/mysql login system for a webproject. After looking through
I am working on a PHP / MySQL stat logging program and am trying
My team working on a php/MySQL website for a school project. I have a

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.