Automatic Checkbox Save w/ jQuery

While making stuff I always try to put in little short cuts to make things go faster, whether its browsing though pages or submitting forms, everything needs sped up. While making the back-end of a discussion form, I used this to save settings without having to submit a form. It just saves everything onclick :D

PHP/HTML/JS
[php]
## CONNECT TO DATABASE
$connection = mysql_connect(“localhost”, “username”, “password”);
mysql_select_db(“databasename”, $connection);


## GET CURRENT SETTINGS
$is_q = mysql_query(“SELECT * FROM `settings` WHERE `id` = ‘1’”);
$is = mysql_fetch_array($is_q);

class=”ajax” />

Refresh the page to see that its still checked/unchecked

[/php]

save.php
[php]
## CONNECT TO DATABASE
$connection = mysql_connect(“localhost”, “username”, “password”);
mysql_select_db(“databasename”, $connection);
if($_GET[‘checked’] == “true”) {
mysql_query(“UPDATE `settings` SET `checkbox` = ‘1’ WHERE `id` = ‘1’”);
} else {
mysql_query(“UPDATE `settings` SET `checkbox` = ‘0’ WHERE `id` = ‘1’”);
}
[/php]

The JS
[php]
$(document).ready(function(){
$(‘input#crazycheckers’).click(function() {
$.get(“save.php”, { checked: $(this).attr(“checked”) },
function(data){
});
});
});
[/php]

Simples :]