Home >Backend Development >PHP Tutorial >求相仿phpmyadmin的复选框功能,带修改功能

求相仿phpmyadmin的复选框功能,带修改功能

WBOY
WBOYOriginal
2016-06-13 10:33:111037browse

求类似phpmyadmin的复选框功能,带修改功能
从数据库中把对应的值列出来,前面加复选框,可以单选或者多选。选择修改按钮针对选中列进行批量修改,类似phpmyadmin的复选框功能。请教大概思路,如何实现此功能?

------解决方案--------------------
ajax 读数据 循环输出数据 数据前面加个------解决方案--------------------
取值的时候
while($row=mysql_fetch_array($res)){
echo "";
echo $row['myClo1']." ".$row['myClo2'];
}//这样数据就加载完成了,以下是操作
用JS就行了,但若你用jquery的话,更方便
$("#alter").click(function(){
$("input[type=checkbox]").each(function(){
if($(this).attr("checked"))
{
$(this).removeAttr("checked");//do sth here

})
})
------解决方案--------------------

PHP code
<?php #test19.phpif(isset($_POST['save'])){    print_r($_POST);    #测试数据    #Array ( [int] => Array ( [0] => 1 ) [name1] => Lucy [name2] => woman [save] => save )}?><meta http-equiv="Content-Type" content="text/html; charset=utf-8"><title>checkbox-edit</title><script language="javascript" type="text/javascript" src="jquery_1.4.2.js"></script><script>$(function(){    $("input[name='edit']").click(function(){        $("input[name^='int']").each(function(){            if($(this).attr("checked")){                var objtd1 = $(this).parent().next("td");                var objtd2 = $(this).parent().next("td").next("td");                //alert("td1-->>"+objtd1+"\ntd2-->>"+objtd2);                objtd1.html("<input type='text' name='name1' value='"+objtd1.text()+"' />");                objtd2.html("<input type='text' name='name2' value='"+objtd2.text()+"' />");            }        });    });});</script><div>    <form name="editdata" action="test19.php" method="post">        <table border="" cellpadding="0" cellspacing="0">            <tr>                <td></td>
<td>Name</td>
<td>Sex</td>            </tr>            <tr>                <td><input type="checkbox" name="int[]" value="1"></td>                <td>TOM</td>                <td>man</td>            </tr>            <tr>                <td><input type="checkbox" name="int[]" value="2"></td>                <td>Lily</td>                <td>woman</td>            </tr>        </table>        <input type="button" name="edit" value="edit">        <input type="submit" name="save" value="save">    </form>
</div><br><font color="#e78608">------解决方案--------------------</font><br>问题应该出在其他地方
HTML code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>   <script language="JavaScript">   <!--   $("document").ready(function(){   $("#btn1").click(function(){   $("[name='checkbox']").attr("checked",'true');//全选   })   $("#btn2").click(function(){   $("[name='checkbox']").removeAttr("checked");//取消全选   })  $("#btn3").click(function(){//输出选中的值   var str="";   $("[name='checkbox'][checked]").each(function(){   str+=$(this).val()+"\r\n";   //alert($(this).val());   })   alert(str);   })   })   -->   </script><div style="background: #eee;"> <form name="form1" method="post" action="">
<input align="center" type="button" id="btn1" value="全选">   <input align="center" type="button" id="btn2" value="取消全选"><input type="button" id="btn3" value="获得选中的所有值">   <br><br> <?phpfor ($i=0; $i<10; $i++)  echo "<input type=checkbox  name=checkbox value=$i>";<div class="clear">
                 
              
              
        
            </div>
</form>
</div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn