hello friends i m trying to make a inbox system in which we select all checkbox with the help of one checkbox and then through ajax pass the value to all checkbox and update the database. but the problem is that they values and being selected one by one and then forming a array
for eg
fst time 2
second time 2,3
third time 2,3,4
and at the sql query where i am trying to get the list of array and break them so that i can update the value in database its also not happening , can anyone help ?here is what i coded.
to get the value of checkbox
$(function(){
$('.massmsgdelbutton').click(function(){
var val = [];
$('.sltchk:checked').each(function(i){
val[i] = $(this).val();
var dataString = 'massmsgdel='+ val;
if(confirm("Sure you want move all these messages to Trash? There is NO undo!"))
{
$.ajax({
type: "POST",
url: "modules/messages/sql_ex.php",
data: dataString,
cache: false,
success: function(html){
alert(html);
}
});
}
});
});
});
my sql code using expode to explode the array
if(isset($_REQUEST['massmsgdel']))
{
$id=$_REQUEST['massmsgdel'];
$myArray[] = explode(',', $id);
echo $id;
$sql=mysql_query("update message set trash='1' where message_id='$myArray'");
}
guys i found the solution .
in the jquery i had to use
instead of
and in sql i had to use
thanks @Frank Allenby for helping me the way out