I have a form where the fields come from the database. Look:
public function tamanhosTabelas($key)
{
while($isfast = mysqli_fetch_object($sql))
{
....
$checked = $isfastTamanhos->IdTamanhos == $isfast->IdTamanhos ? 'checked' : null;
$visualizar .= '<div class="bloco Grade"><input type="checkbox" name="TamanhoGrade[]"
value="'.$isfast->IdTamanhos.'" '.$checked.'><br><span style="font-weight: bold">'.$isfast-
>Tamanhos.'</span></div>';
}
return $visualizar;
}
I have the following result:
However, I need to check which field was selected or not. My code looks like this:
if($_POST)
{
....
$tamanhoGrade = $_POST["TamanhoGrade"];
echo $metodos->alterarGrade($tamanhoGrade);
}
Method alterarGrade($tamanhoGrade):
public function alterarGrade($tamanhoGrade)
{
for($i = 0; $i <= count($tamanhoGrade); $i++)
{
if($tamanhoGrade[$i] != null)
{
echo "Selected sizes " .$tamanhoGrade[$i]."<br>";
}
else
{
echo "Unselected sizes " .$tamanhoGrade[$i]."<br>";
}
}
}
But it only brings the selected fields. I would like to take the fields that are not marked to exclude from the database. I've tried using the isset()
, but I also couldn't.
Sorry for my English.