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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T04:25:07+00:00 2026-06-06T04:25:07+00:00

while entering the data in the textfield on the browser, it should fetch the

  • 0

while entering the data in the textfield on the browser, it should fetch the data from the database and display accordingly. (ex: like google).
Here is my php code:

    <?php
    mysql_connect("localhost","root","MobixMySQL") or die(mysql_error());
    mysql_select_db("filter") or die(mysql_error());
    $partialStates = $_POST['partialStates'];
    $states = mysql_query("SELECT name FROM list1 WHERE name LIKE "%$partialStates%"");
    while($state = mysql_fetch_assoc($states)) {
    echo "<div>".$state['name']."</div>";
   }
   ?>

And below is my html code:

   <html>
   <head>
   <script type="text/javascript" src="jquery.js"></script>
   <script type="text/javascript">
     function getStates(value){
     $.post("getStates.php",{partialStates:value},function(data){
     $("#results").html(data);
    });
    }
   </script>
    </head>
    <body>
    <input type="text" onKeyUp="getStates(this.value)" >
    <div id="results"></div>
    </body>
    </html>

Pls suggest me where am wrong….!!!

  • 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-06T04:25:08+00:00Added an answer on June 6, 2026 at 4:25 am

    Error with your quotes in the SQL…along with injection. Check out PDO for future development

    $partialStates = mysql_real_escape_string($_POST['partialStates']);
    $states = mysql_query("SELECT `name` FROM list1 WHERE `name` LIKE '%$partialStates%'");
    

    EDIT

    Since you’re using jQuery trying changing your onkeyup event. If you are still getting errors use something like FireBug or your browsers javascript debugger to check for further errors. Try the following (untested):

    <script type="text/javascript">
    $(document).ready(function() {
        $('input#myFilter').keyup(function(event) {
            $.post("getStates.php",{partialStates:$(this).val()},function(data){
                $("#results").html(data);
            });
        }).keydown(function(event) {
            if (event.which == 13) {
                event.preventDefault();
            }  
        });
    });
    </script>
    </head>
    <body>
    <input type="text" id="myFilter">
    <div id="results"></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

While launching the application in my iPhone, I need to download the data from
I want to validate my text are while entering data. I had written code
A group of people have been inconsistently entering data for a while. Some people
While reading through another question here, on creating a URL shortening service, it was
I'm creating comments stored in a MySQL database. I'm logging the php time function
I am getting strange error while inserting data into mysql table column. Details: Create
I'm having a bit of trouble with entering data into several columns of a
I have written a code that searches specific string from database table.what i want
Kohana mentions they use mysql_real_escape_string to sanitize database inputs in their documentation. However, while
i am preparing myself for importing data from excel sheet to sql server 2005.I

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.