提交表单后,如何保持我的复选框在foreach循环内

时间:2019-02-21 14:10:24

标签: php html

我怎样才能检查我的foreach循环中的复选框,甚至 表格提交后。还将复选框的值插入到 数据库

if ( $a > 0){
    while($row = mysqli_fetch_assoc($aresult)){
        $apps[] = $row;
    }
}
if ( $r > 0){   
    while($col = mysqli_fetch_assoc($rresult)){
        $roles[] = $col;
    }
}
foreach ($apps as $app){
    echo "<th>";
    echo $app['app_name'];
    echo "</th>";
}   
foreach ($roles as $role){
    echo "<tr>";
    echo "<th>$role[role_name]</th>";
    foreach ($apps as $app){
        echo "<td>";
        $ap = $app['app_id'];
        $ro = $role['role_id'];
        echo "<div id='checkbox-container'>";
        echo "<input type='checkbox'  id='myCheck' name='checkbox[]' value = '$ro,$ap'>";
        echo "</div>";
        echo "</td>";
    }
}   
?>

我还需要其他什么替代方案才能实现这一目标?

0 个答案:

没有答案