I have a checkbox list with 10 options ik the image just have 9:
and a db:
How can I compare the input in the checkbox list with the information inside the column requerimientos
in my db?, it means values from the checkbox list must contain all of the values from requerimientos
and it will happen with every id, just i didn't fill the other values yet, hope this clarify it
This is what I got, if it seems I have no clue what I am doing it can't be more accurate, but I dont give up. XD
<form action="" method="post">
<?php
$query = $mysqli->query("SELECT idclasificacion,clasificacion FROM clasificacion");
while ($rows = $query->fetch_array()) {
echo'<div class="list-group-item" id='. $rows['idclasificacion'] .'>
<label>
<input type="checkbox" name="requerimiento[]" id="" value="'.$rows['clasificacion'].'">'. $rows['clasificacion'] . '
</label>
</div>';
}
?>
<button class="btn btn-primary" type="submit">Ingresar</button>
</form>
<?php
//extrae los requerimiento seleccionados en forma de string, notar que requerimiento va sin []
if (isset($_POST['requerimiento'])){
$requerimientos = implode ( ',', $_POST['requerimiento']);
echo $requerimientos;
}else {
echo'no ha selecionado ningun requerimiento para su evento';
}
echo '<br>';
$query = $mysqli->query("SELECT requerimientos FROM tipologia");
$rows = $query->fetch_assoc();
var_dump($rows);
$requetipo=explode(',', $rows['requerimientos']);
var_dump($requetipo);
$validacion=in_array($requerimientos,$requetipo);
var_dump ($validacion);
?>