In summary, I need the query to be made according to the number of options selected in the Select field.
I do not know if I can explain myself clearly. Until now the code that I have is the following, however it only shows the result of a selected option.
function CargarProductos(thematique){
$.ajax({
type: "POST",
url: 'b.php',
data: {thematique: thematique},
beforeSend: function () {
$("#Prresul").html("espere");},
success: function (response) {
$("#Prresul").html(response);}});
}
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<form id="form">
<select name=thematique[] multiple onchange='CargarProductos(this.value)'>
<option value="MIE"> MIE </option>
<option value="Migration"> Migration </option>
<option value="Reunification_familiale"> Reunification familiale </option>
</select>
</form>
<input type="button" value="guardar" onclick="CargarProductos(this.value)">
<div id="Prresul"></div>
<?php
foreach ( (array) $_POST['thematique'] as $thematique)
{
require("../conexion.php");
$consulta="SELECT * FROM prueba WHERE nombre = '".$thematique."'";
if($resultado = $mysqli->query($consulta)){
while ($var_fila=$resultado->fetch_array()){
echo "<td>".$var_fila["0"]."</td>";
echo "<td>".$var_fila["1"]."</td>";
echo "</tbody>";
}}
else
{
echo "No hay Registros";
}
}?>