本文共 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> </td> <td width="742"> <input type="text" name="renyuanName" value="<?php echo $name ?>"> </td> </tr> <tr> <td>SIM号:</td> <td> </td> <td> <input type="text" name="sim" value="<?php echo $sim?>" > </td> </tr> <tr> <td> IME号: </td> <td> </td> <td> <input type="text" name="ime" value="<?php echo $ime?>" > </td> </tr> <tr> <td> 邮箱: </td> <td> </td> <td> <input type="text" name="mail" value="<?php echo $email?>"> </td> </tr> <tr> <td> 电话: </td> <td> </td> <td> <input type="text" name="tel" value="<?php echo $tel?>">---设置global本页面的全局变量 </td> </tr> <tr> <td> 登陆用户: </td> <td> </td> <td> <input type="text" name="username" value="<?php echo $username?>" > </td> </tr> <tr> <td width="103"> </td> <td width="103"> </td> <td width="103"> </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/