whats wrong with this?
EDIT:
$check = $row['publish'] == 1 ? 'true' : 'false';
It works when I want to unpublished, but if the checkbox is empty I cannot publised.
OnClick="doAction(<?php echo $check;?>, <?php echo $id;?>);"
function doAction(check,id){
$.ajax({
type: "GET",
url: "test.php",
data: "check=" + check + "&id=" + id,
success: function(msg){
alert( "Data Saved: " + msg );
}
});
}
and the file test.php:
$id = $_GET['id'];
$check = $_GET['check'];
if ($check == "false"){
$query = mysql_query("update article set publish = 1 where id =" . $id);
echo "Published";
}
else {
$query = mysql_query("update article set publish = 0 where id =" . $id);
echo "Unpublished";
}
I cannot display the id in the test.php file.it gives me nothing. But in the doAction parameters are(.., id) so it's been sent but I don t receive it in the ajax call and then in file. Why?
$checkas checked or unchecked. And, In test.php, condition inifis$check == "false". Why?$.ajax({ type: "GET", url: "test.php?check="+ check + "&id = " + id, success: function(msg){ alert( "Data Saved: " + msg ); } });