我在phpmyadmin中有一個名爲fleet hire motors
的數據庫,並且該數據庫中有一個名爲customer
的表。在html文本框中顯示phpmyadmin單元格的值
在該表中列出了名爲customerID
和Surname
的列。我已經在一頁上做了一些編碼,讓用戶選擇customerID
來編輯Surname
。
在下一頁我想要一個文本框。在該文本框中,默認值應該是當前的Surname
。
所以,如果我是用customerID
1編輯客戶(其姓是目前Brown
,我想換Green
)第二頁會顯示Surname: [Brown]
,其中[]圍住一個文本框。
我目前沒有任何代碼,並希望保持它主要是PHP。第一頁稱爲editcustomer.php
,第二頁稱爲editcustomer2.php
。
任何幫助表示讚賞。
我當前的代碼是:
<html> <head> <title>Edit Customer</title> </head><body>
<?php mysql_connect("localhost","username","password") or die(mysql_error());
mysql_select_db("fleet hire motors") or die(mysql_error()); ?>
<?php
$CustomerID = $_GET["CustomerID"];
$query=mysql_query(" SELECT * FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error());
while ($row = mysql_fetch_array($query)) {
b$CustomerID = $row["CustomerID"];
} ?>
First Name: <input name="FirstName" type="text" value="
<?php
$FirstName = $_GET["CustomerID"];
include 'db.php';
$query=mysql_query(" SELECT FirstName FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error());
?> ">
<br> <input name="submitbtn" type="submit" value="Save"> <input name="resubmitbtn" type="submit" value="Reset"> </form> </body> </html>
對不起,所有的編輯,因爲我是新來的StackOverflow,只是學習如何做到這一點。
我現在已經更新了我的編碼,這要歸功於響應,但它仍然不起作用。我最新的編碼是:
<html>
<head>
<title>Edit Customer</title>
</head>
<body>
<?php
mysql_connect("localhost","username","password") or die(mysql_error());
mysql_select_db("fleet hire motors") or die(mysql_error());
?>
<?php
$CustomerID = $_GET["CustomerID"];
$query=mysql_query(" SELECT * FROM customer WHERE CustomerID = '$CustomerID' ") or die(mysql_error());
$row = mysql_fetch_array($query);
if (!$row || !is_array($row)){
$CustomerID = 0;
$CustomerFirstName = '';
}
else {
$CustomerID = $row["CustomerID"];
$CustomerFirstName = $row['FirstName'];
}
?>
First Name: <input name="FirstName" type="text" value="<?php echo $CustomerFirstName; ? >">
<input name="submitbtn" type="submit" value="Save">
<input name="resubmitbtn" type="submit" value="Reset">
</form>
</body>
</html>
這不給我任何東西在文本框中,我的提交按鈕不起作用。
您可以將當前的代碼呢? – Namal
顯示你已經嘗試過什麼? –