Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

127
Views
seleccione distinto donde id en una lista de valores - me da un resultado incorrecto
$('#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); }

Tengo las seis identificaciones en la tabla y cada una de ellas con un correo distinto
entonces el resultado debe ser 6 y no 0
por favor ayuda

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Creo que tu problema está en tu función php

Probablemente $ids es una matriz, por lo que debe transformarla en una cadena usando implode

como esto

 function btn_mails($ids){ global $db; $sq = "select distinct mail from clients where id in (" . implode(', ', $ids) . ")"; $st = $db->prepare($sq); $st->execute(); $arr = $st->fetchAll(); echo count($arr); }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!