click and submit button id with jquery

Posted by user836910 on Stack Overflow See other posts from Stack Overflow or by user836910
Published on 2012-06-01T16:35:57Z Indexed on 2012/06/01 16:40 UTC
Read the original article Hit count: 199

Filed under:
|
|

my aim is to submit a button id using jquery into a database im only interested in the button not its value.

$("#button").click(function(){
var p = $(this).attr("id");

$.ajax({
type: "POST",
url: subpage.php",
data: 'b='+p,
cache: false,
success: function(html)
{
//process live

}
 });
return false;
});

subpage.php

$item = $_POST['b'];
$query = mysql_query("SELECT * FROM table WHERE  id = '25' AND bttnid = '$item'");
if(count($query)==0){
mysql_query("INSERT INTO table VALUES ('','25','$item') ");
    }

it doesn't submit. please assit

© Stack Overflow or respective owner

Related posts about php

Related posts about jQuery