1
I have the following appointment
$turmas= $wpdb->get_results(
$wpdb->prepare(
"SELECT nome FROM turmas WHERE id= '%d' ",
$_POST['idSerie']), ARRAY_A );
When I get $_POST['idSerie']
with an index only it works, but when I get a array
no, I need to make a for
to take each index, perform this query and save to another array
.
For example: if the user marks two series I have to return the classes of these two series.
I’m trying to do it this way, only it’s not working.
$count = count($_POST['idSerie']);
$turmas[];
for ($i = 0; $i < $count; $i++)
{
$turmas[] = $wpdb->get_results(
$wpdb->prepare(
"SELECT nome FROM turmas WHERE id= '%d' ",
$_POST['idSerie'][i]), ARRAY_A);
}
In case you need him to get the
id
within the array that will come fromidSerie
?– Bulfaitelo
yes, the variable $_POST['idSerie'] is like this ["10", "11"], I need to separate and search the classes with id 10 me then classes with id 11
– Larissa silva
then It would be 2 queries or can be done in the same query ?
– Bulfaitelo
would be two queries, or even how many series the user select, if you can do this in one query only, even better, but this array does not have a fixed number, the user can select as many series as he wants
– Larissa silva
Ta good I’ll do so that is just a query there you test. and give me a feedback
– Bulfaitelo