提交后如何保留在foreachloop中选中的选定框

时间:2019-07-09 17:22:24

标签: php html bootstrap-4

如何保留提交后选中/选中的所选框...

        <td>
        <div class="btn-group btn-group-toggle" data-toggle="buttons">
         <label class="btn btn-sm btn-outline-success">
         <input type="checkbox" name="total_odds[]" id="total odds" value="<?php echo $game->odds; ?>" autocomplete="off"> <?php echo $game->odds; ?>
        </label>
        </div>
        </td>

if(isset($_POST["submit"])){
    if(empty($_POST["total_odds"])){
    $main_odds_error = "<div class='error-msg'>You have not selected any odds ☺</div>";
    }else{
    $main_odds      = $_POST["total_odds"];
    $total = 1;
    if(!empty($main_odds)){
        foreach ($main_odds as $final_odd){
                $total   = $total * $final_odd;
        }
    }
    $count_main_odd = count($main_odds);
    $total_odds = number_format($total, 2); 
}
}

我希望它保留选择的任何奇数...

0 个答案:

没有答案