using jquery to load data from mysql database

Posted by Ieyasu Sawada on Stack Overflow See other posts from Stack Overflow or by Ieyasu Sawada
Published on 2011-01-13T14:45:26Z Indexed on 2011/01/13 14:53 UTC
Read the original article Hit count: 218

Filed under:
|

I'm currently using jquery's ajax feature or whatever they call it. To load data from mysql database. Its working fine, but one of the built in features of this one is to load all the data which is on the database when you press on backspace and there's no character left on the text box.

Here's my query:

SELECT * FROM prod_table WHERE QTYHAND>0 AND PRODUCT LIKE '$prod%' OR P_DESC LIKE '$desc%' OR CATEGORY LIKE '$cat%'

As you can see I only want to load the products which has greater than 0 quantity on hand.

I'm using this code to communicate to the php file which has the query on it:

$('#inp').keyup(function(){


                var inpval=$('#inp').val();

            $.ajax({
                type: 'POST',
                data: ({p : inpval}),
          url: 'querys.php',
          success: function(data) {
            $('.result').html(data);

          }





        });

    });

Is it possible to also filter the data that it outputs so that when I press on backspace and there's no character left. The only products that's going to display are those with greater than 0 quantity?

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery