$('#btnmails').on('click', function(){
let ids = $.map($('.atitle'), (e) => $(e).attr('data-id'));
ids = JSON.stringify(ids);
console.log(ids); // ["26","25","24","23","22","21"]
$.post('pro.php', {fn: 'btn_mails', args: [ids]}, function(data){
console.log(data); // 0 - but it is not true
});
});
pro.php
function btn_mails($ids){
global $db;
$sq = "select distinct mail from clients where id in ('" . $ids . "')";
$st = $db->prepare($sq);
$st->execute();
$arr = $st->fetchAll();
echo count($arr);
}
I have all six ids in table and each of them with a distinct mail
so result should be 6 and not 0
pls help