时间:2017-06-30 07:26:41

标签: 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(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 个答案:

答案 0 :(得分:0)

你的问题没有清除。

  

假设'edit'是表格中的一列,如果它是1,则检查其他未选中

<input type="checkbox"   name="edit[]" value="<?php echo $data2['id']; ?>"
    <?php echo ($data2['edit'] == 1)? 'checked=""' : ''? >