SELECT * FROM contacts WHERE id = $_SESSION['user_id'] ORDER BY name ASC LIMIT 5
that pulls out all my data and only gives me 5 results.
Now my goal is to have a little button that opens up a model box with jquery (this I can manage on my own) with a form asking the user to input a number then that number will be sent via post or get to $PHP_SELF and update a local variable with the number the user inputed, then that variable will be used to update the database to increase or decrease the LIMIT value.
I have looked all over the web (with google) to look for submitting a form using AJAX but all the examples i've found don't work for me.
When the user submits the number and the sql query is executed and updated for the outputed table to dynamically update according to the new LIMIT value all without ever refreshing the page to the user.
my jquery code is:
$(document).ready(function(){ $("form#form").submit(function() { // we want to store the values from the form input box, then send via ajax below var val = $('input[name=new_value]').attr('value'); $.ajax({ type: "post", url: "process.php", data: "val="+ val, cache: false, success: function(){ $('form#form').hide(function(){$('.success').fadeIn();}); } }); return false; }); });
then my php code is:
$new_val = $_POST['new_val']; $_val = "UPDATE `settings` SET `display_limit` = {$new_val} WHERE `user_id` = {$_SESSION['user_id']}"; mysql_query($_val) or die(mysql_error()); }
and my form is simple:
<form id="form"> <input type="text" id="new_val" name="new_val" class="text" /> <input type="submit" name="limit" id="submit" /> </form>
|