zoukankan      html  css  js  c++  java
  • 点击修改之后,先施行查询功能,并把数据添加到对应的框中
    定义头部文件,防止写中文时乱码 
       header("content-type:text/html;charset=utf-8");
     
    接收数据
        $id = $_GET["id"];
     
    处理数据
         1--连接数据源   mysql_connect
         $db = mysql_connect("localhost","root","root");
         2--选择数据库   mysql_select_db 
         mysql_select_db( "db1811" , $db );//选择了$db下的db1811数据库
         3--设置字符编码 (防止乱码) mysql_query
         mysql_query( "set names utf8" );
               4--编写sql语句   
         $sql = "select * from score where sid=$id";
         5--执行sql语句   mysql_query
         $res = mysql_query( $sql );
         $arr = mysql_fetch_array( $res );
     
    处理结果 (将服务器的返回值分别添加至对应的表单文本框中的value属性中)
         <form action="updateDo.php" method="post">
             <input type="hidden" name="id" value="<?php echo $arr["sid"];?>" />
             用户名 : <input type="text" name="sname" value="<?php echo $arr["sname"];?>"/><br>
             h5成绩: <input type="text" name="h5" value="<?php echo $arr["h5"];?>"/><br>
             js成绩: <input type="text" name="js" value="<?php echo $arr["js"];?>"/><br>
             <input type="submit" value="确认修改"/>
         </form>
     
    再确认修改
    定义头部文件,防止写中文时乱码 
       header("content-type:text/html;charset=utf-8");
     
    接收数据
         $id = $_POST["id"];
         $sname = $_POST["sname"];
         $h5 = $_POST["h5"];
         $js = $_POST["js"];
     
    处理数据
         1--连接数据源   mysql_connect
         $db = mysql_connect("localhost","root","root");
         2--选择数据库   mysql_select_db 
         mysql_select_db( "db1811" , $db );//选择了$db下的db1811数据库
         3--设置字符编码 (防止乱码) mysql_query
         mysql_query( "set names utf8" );
         4--编写sql语句   
         $sql = "update score set sname='$sname',js=$js,h5=$h5 where sid=$id";
         5--执行sql语句   mysql_query
         $row = mysql_query($sql);
     
    返回结果
         if( $row ){
              echo "<script>alert('修改成功');location.href='index.php'</script>";
         }else{
              echo "<script>alert('修改失败');location.href='index.php'</script>";
         }
  • 相关阅读:
    Jsp语法、指令及动作元素
    java之Cookie详解
    servlet请求转发、包含以及重定向
    20181114_特性
    20181114_反射_泛型反射
    20181112_反射基础_对象获取
    20181110_wait和async
    20181106_线程之异常_取消_变量_安全Lock
    20181105_线程之Task
    20181104_C#线程之Thread_ThreadPool_使用Thread实现回到和带参数的回调
  • 原文地址:https://www.cnblogs.com/tis100204/p/10297184.html
Copyright © 2011-2022 走看看