0

我想在我的 mysql 数据库中有一个单元格作为文本框中的值。

我想在文本框中为 CustomerID 为 1 的人设置 FirstName 列。

这是我的编码。

<html>
<head>
<title>Edit Customer</title>
</head>
<body>
<?php
mysql_connect("localhost","cmcclintock","000547") or die(mysql_error());
mysql_select_db("fleet hire motors") or die(mysql_error());
$CustomerID = $_GET["customerid"]; 
$query=mysql_query("SELECT FirstName FROM customer WHERE CustomerID = $CustomerID") or     die(mysql_error()); 
$row = mysql_fetch_array($query);


echo ($CustomerID);
echo ($query);
echo ($row);


?> 
<form name="custedit2" method=GET action="editcustomersubmit.php">
First Name: <input name="FirstName" type="text" value="<?php echo ($query); ?>">
<input name="submitbtn" type="submit" value="Save">
<input name="resubmitbtn" type="submit" value="Reset">
</form>
</body>
</html>

希望这足以解释我在寻找什么。

4

1 回答 1

0
<input name="FirstName" type="text" value="<?php echo ($row['FirstName']); ?>">

$row 是存储结果集的位置,因此您可以使用它来显示所需的列

于 2013-08-22T04:33:50.543 回答