php跟mysql交互获取表单内容,编辑

  • 1,791
  • 阅读模式
    <?php
    $conn=mysql_connect('localhost','root','12345678');
    if($conn){
        print_r($conn);
    }else{
        exit;
    }
    $sql="use test";
    $rs=mysql_query($sql,$conn);
    $sql='select * from stu';
    $rs=mysql_query($sql,$conn);
    var_dump($rs);
    $list=array();
    while($row=mysql_fetch_assoc($rs)){
        $list[]=$row;
    }
    //二维数组
    //print_r($list);
    //Array ( [0] => Array ( [id] => 22 [sname] => ijabde [yy] => ijabde ) [1] => Array ( [id] => 61 [sname] => stu5' [yy] => yy33333 ) [2] => Array ( [id] => 83 [sname] => bvntmh [yy] => bvntmh ) [3] => Array ( [id] => 58 [sname] => xingming58 [yy] => yyy585858 ) ) 
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>新建网页</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="" />
    </head>
        <body>
            <h2> 公益一期学员</h2> 
            <table border='1'>
                <tr>
                    <td>id</td>
                    <td>姓名</td>
                    <td>YY</td>
                    <td>操作 </td>
                </tr>
                <?php
                foreach ($list as $v) {
                    echo  '<tr>';
                    echo '<td>',$v['id'],'</td>';
                    echo '<td>',$v['sname'],'</td>';
                    echo '<td>',$v['yy'],'</td>';
                    echo '<td></td>';
                    echo '<td><a href="mysql07-1.php?id=',$v['id'],'">编辑</a></td>';
                    echo '</tr>';
                }
                ?>
            </table>
        </body>
    </html>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>新建网页</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="description" content="布尔教育 http://www.itbool.com" />
    </head>
        <body>
            
            <form action="mysql04.php" method="post">
                学生id:<input type="text" name="id" /></br>
                新姓名:<input type="text" name="sname" /></br>
                新YY:<input type="text" name="yy" /></br>
                <input type="submit" value="修改 提交" />
            </form>
        </body>
    </html>

 

weinxin
我的微信
这是我的微信扫一扫
开拓者博主
  • 本文由 发表于 2016年7月22日16:13:07
  • 转载请务必保留本文链接:https://www.150643.com/289.html
匿名

发表评论

匿名网友 填写信息