mercredi 30 octobre 2019

Php submit form checkbox with checked box

I have a db where read all information I read a optino and the stato 1 is confirmed and 0 not... I create a table where anyone can update, check or remove check and after the submit I update all data but in the submit I see only the "checked"... the other not..

$c_row = current($row);

if ($y > 1) {
    echo "<form name=salvo method=post action='dettaglio.php?tipo=1'>";

    $id = substr($c_row,0,strpos($c_row, '|'));
    $stato = substr($c_row,strpos($c_row, '|')+1,1);

    echo "<td class='tg-dett' align=center>";

    if ($stato == 1) {
        echo "<input type='checkbox' name='chkColor[]' value='$c_row' checked>";
    } else {
        echo "<input type='checkbox' name='chkColor[]' value='$c_row' >";
    }

    echo "</td>";

    for($i = 0; $i < count($_POST["chkColor"]); $i++)
    {
        if(trim($_POST["chkColor"][$i]) != "") {
            echo "chkColor $i = ".$_POST["chkColor"][$i]."<br>";
        }
    }
}

the output is only checked, If anyone remove a check don't appear to output




Aucun commentaire:

Enregistrer un commentaire