表table1:(id   studentname)
html里如何用循环输入框 读出table1的所有数据
然后修改数据后用表单提交,从而批量修改table1的所有数据
求提交页代码和接收页代码,本人初学,望能提供代码,谢谢了

解决方案 »

  1.   


    别打击楼主,不难,分也不少。关键是要有时间,相信重赏之下必有勇夫。1.html里如何用循环输入框 读出table1的所有数据
    2.修改数据后用表单提交,从而批量修改table1的所有数据2个问题.代码也不会很多 例子就行了
      

  2.   

    这个...大体看起来用form post一个数组,然后用php一个个update到数据库里不就行了么? 看起来是常规应用?
      

  3.   

    以下,没有调试,你自己拿数据库调试一下..可能有点小错误~<?php
    $mysqli = new mysqli("localhost", "my_user", "my_password", "world");
    if (mysqli_connect_errno()) {
        printf("Connect failed: %s\n", mysqli_connect_error());
        exit();
    }$query = "SELECT id,studentname FROM table";
    $result = $mysqli->query($query);
    if (isset($_POST['send']){
    $studentsname = $_POST['studentname'];
    foreach ($studentsname as $key=>$value){
    $query .= "UPDATE table SET studentname='.$value.' WHERE id='.$key.';";
    }
    $mysqli->multi_query($query);
    }?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Title</title>
    </head>
    <body bgcolor="#ffffee">
    <form method="post">
    <table>
    <?php foreach ($result as $value) {?>
    <tr><td>studentname: <input type="text" name="studentname[<?php echo $value->id?>]" value="<?php echo $value->studentname;?>"/></td></tr>
    <?php }?>
    </table>
    <p><input type="submit" name="send" value="提交" /></p>
    </form>
    </body>
    </html>