Javascript 在php中是否选中了while循环复选框
编辑:这里我正在经历一个循环,我不知道如何进行复选框检查或不使用php。请检查我的代码,让我知道需要在代码中添加什么 请帮忙。提前谢谢Javascript 在php中是否选中了while循环复选框,javascript,php,jquery,ajax,mysqli,Javascript,Php,Jquery,Ajax,Mysqli,编辑:这里我正在经历一个循环,我不知道如何进行复选框检查或不使用php。请检查我的代码,让我知道需要在代码中添加什么 请帮忙。提前谢谢 <?php $con = new mysqli($host,$user,$pass,$db_name); $select1 = "select * from $menu_table where status='A' order by menu_si_no asc"; $result1 = $con->query($select1) or die(
<?php
$con = new mysqli($host,$user,$pass,$db_name);
$select1 = "select * from $menu_table where status='A' order by menu_si_no asc";
$result1 = $con->query($select1) or die(mysqli_error($con));
while($data1 = $result1->fetch_array())
{
$con = new mysqli($host,$user,$pass,$db_name);
$selectac = "select * from $access_table where id='".$_GET['id']."'";
$resultac = $con->query($selectac) or die(mysqli_error($con));
$dataac = $resultac->fetch_array();
?>
<li class="menu-list">
<span style="color:#ff0000;"><?php echo $data1['menu_name']; ?></span>
<span ><input type="hidden" value="<?php echo $data1['menu_name']; ?>"></span>
<?php
$con = new mysqli($host,$user,$pass,$db_name);
$select2 = "select * from $submenu_table where menu_id='".$data1['id']."' and status='A'";
$result2 = $con->query($select2) or die(mysqli_error($con));
$count2 = $result2->num_rows;
while($data2 = $result2->fetch_array())
{
$con = new mysqli($host,$user,$pass,$db_name);
$select3 = "select * from $access_table";
$result3 = $con->query($select3) or die(mysqli_error($con));
$count3 = $result3->num_rows;
while($datas = $result3->fetch_array())
{
$ac_id[$j] = $datas['submenu_id'];
?>
<ul class="child-list">
<span style="color:#1f30ef;width:150px;">
<input type="checkbox" name="submenu[]" value="<?php echo $data2['id']; ?>"><?php echo $data2['submenu']; ?></span>
<span class="ch_box" style="width:100px;">
<input type="checkbox" name="add[]" value="<?php echo $data2['id']; ?>">Add
<input type="checkbox" name="edit[]" value="<?php echo $data2['id']; ?>">Edit
<input type="checkbox" name="delete[]" value="<?php echo $data2['id']; ?>">Delete</span>
</ul>
<?php
}
}
?>
</li>
<?php
}
?>
你的问题没有回答
假设“编辑”是表中的一列,如果是1,则选中,否则不选中
你的问题是什么?它是未清理的…请格式化您的代码,并添加一些解释到您的问题嗨,伙计们。我的表中有10个子菜单,每个子菜单都有添加编辑删除复选框。。用于为用户分配菜单访问优先级。。然后,我想检查我分配了哪些菜单如何选中复选框,如果条件和值来自两个,而loopssorry。。我有多个复选框。那么我如何检查循环中的所有复选框呢?我假设edit、add、delete是表中的三个不同列。这里我使用了edit、add、delete作为标志。根据我的建议,如果选中,则为列使用“1”或“0”。
<input type="checkbox" name="edit[]" value="<?php echo $data2['id']; ?>"
<?php echo ($data2['edit'] == 1)? 'checked=""' : ''? >