博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php +mysql 查询要修改的记录并把属性赋值给表单控件
阅读量:4115 次
发布时间:2019-05-25

本文共 2399 字,大约阅读时间需要 7 分钟。

 

我是一个php的初学者,下面是我自己找资料总结的,希望对大家有帮助。。。。。

**********************************************************************************************************************************************************************

 

<form action="modifyResult.php" method="get" name="addform">

     <table align="left;width:1000px">
       <?php
          //print_r($_POST);
          //print_r($_POST['id']);
          //对于数组重新赋值
          $array = $_POST['id'];
          //echo $array[0];//取数组的第一个元素
          if(count($array) > 0){
            Global $id;
   $id = $array[0];
             //echo "id=".$id;
             $con = mysql_connect("ip.haso-soft.com:12038/bscs","hasoDev","hasoDev1239");
             @mysql_query("SET character_set_connection=utf8, character_set_results=utf8, character_set_client=binary",$con);
             if (!$con)
              {
                die('Could not connect: ' . mysql_error());
              }
           mysql_select_db("bscs", $con);

              // 查询一条记录:

           $query = "select * from renyuan where id = $id";
           $result = mysql_query($query);
          
          if   (!$result){
            echo   'MySQL查询一条记录命令失败! ';
          }
          ;
          while($row=mysql_fetch_object($result))    注意:mysql_fetch_object() 与mysql_fetch_array不同的是前者返回的是对象而后者返回的是数组
          {
            //定义本页面的全局变量,可以在本页面任何地方进行调用,包括require(), include() 加入的文件
            Global $sim,$name,$ime,$email,$tel,$username;
            $sim = $row->sim;
            $name= $row->name;
            $ime = $row->ime;
            $email= $row->email;
            $tel = $row->tel;
            $username = $row->username;  
          }
        }
      ?>
     
       <tr>
         <td width="103">人员名:</td>
         <td>&nbsp;</td>
         <td width="742">
          <input type="text" name="renyuanName" value="<?php  echo $name  ?>">
         </td>
       </tr>
        <tr>
         <td>SIM号:</td>
         <td>&nbsp;</td>
         <td>
             <input type="text" name="sim" value="<?php  echo $sim?>" >
         </td>
       </tr>
       <tr>
         <td> IME号: </td>
         <td>&nbsp;</td>
         <td>
          <input type="text" name="ime" value="<?php  echo $ime?>" >
         </td>
       </tr>
       <tr>
         <td> 邮箱: </td>
         <td>&nbsp;</td>
         <td>
          <input type="text" name="mail" value="<?php  echo $email?>">
         </td>
       </tr>
       <tr>
         <td> 电话: </td>
         <td>&nbsp;</td>
         <td>
          <input type="text" name="tel" value="<?php  echo $tel?>">---设置global本页面的全局变量
         </td>
       </tr>
       <tr>
         <td> 登陆用户: </td>
         <td>&nbsp;</td>
         <td>
          <input type="text" name="username" value="<?php  echo $username?>" >
         </td>
       </tr>
       <tr>
           <td width="103">&nbsp;</td>
           <td width="103">&nbsp;</td>
           <td width="103">&nbsp;</td>
       </tr>
       <tr>
         <td width="103">
          <input type="submit" name="modify" value="修改" >
         </td>
       </tr>
       <input type="hidden" name="modifyId" value="<?php echo $id ?>" />
     </table>
     </form>

*************************************************************************************************************************************************************************

转载地址:http://nqupi.baihongyu.com/

你可能感兴趣的文章
element-ui全局自定义主题
查看>>
facebook库runtime.js
查看>>
vue2.* 中 使用socket.io
查看>>
openlayers安装引用
查看>>
js报错显示subString/subStr is not a function
查看>>
高德地图js API实现鼠标悬浮于点标记时弹出信息窗体显示详情,点击点标记放大地图操作
查看>>
初始化VUE项目报错
查看>>
vue项目使用安装sass
查看>>
HTTP和HttpServletRequest 要点
查看>>
在osg场景中使用GLSL语言——一个例子
查看>>
关于无线PCB中 中50欧姆的特性阻抗的注意事项
查看>>
Spring的单例模式源码小窥
查看>>
后台服务的变慢排查思路(轻量级应用服务器中测试)
查看>>
MySQL中InnoDB事务的默认隔离级别测试
查看>>
微服务的注册与发现
查看>>
bash: service: command not found
查看>>
linux Crontab 使用 --定时任务
查看>>
shell编程----目录操作(文件夹)
查看>>
机器学习-----K近邻算法
查看>>
HBASE安装和简单测试
查看>>