我有一个用 HTML 创建的表单。有时,我们的代表需要回来编辑他们之前输入表格的数据。我已经设置了他们可以输入 OrderForm ID(例如 1234)的位置,它将相应地填充字段。我希望他们能够更新或更改字段,然后当他们点击提交时,它将创建一个附加 .1 的新数字(1234.1),并更新 MySQL 数据库。
我已经能够创建表单、填充搜索字段,但不知道如何更新和分配“.1”给表单 ID。
这是我的代码:
<?php
$connection = mysql_connect('localhost','username','*******') or die ("Couldn't connect to server.");
$db = mysql_select_db('DBName', $connection) or die ("Couldn't select database.");
// -------------------------------------------------------------------
// Field Names
// -------------------------------------------------------------------
$drepid=mysql_real_escape_string($_POST['drepid']);
$datepicker=mysql_real_escape_string($_POST['datepicker']);
$repemail=mysql_real_escape_string($_POST['repemail']);
$dateneeded=mysql_real_escape_string($_POST['dateneeded']);
$description=mysql_real_escape_string($_POST['description']);
$qty=mysql_real_escape_string($_POST['qty']);
$pgsizeh=mysql_real_escape_string($_POST['pgsizeh']);
$pgsizew=mysql_real_escape_string($_POST['pgsizew']);
$pageno=mysql_real_escape_string($_POST['pageno']);
$stock=mysql_real_escape_string($_POST['stock']);
$ink=mysql_real_escape_string($_POST['ink']);
$inknote=mysql_real_escape_string($_POST['inknote']);
$rfq=mysql_real_escape_string($_POST['rfq']);
$finishing=mysql_real_escape_string($_POST['finishing']);
$dfirstname=mysql_real_escape_string($_POST['dfirstname']);
$dlastname=mysql_real_escape_string($_POST['dlastname']);
$dorganization=mysql_real_escape_string($_POST['dorganization']);
$email=mysql_real_escape_string($_POST['email']);
$daddress1=mysql_real_escape_string($_POST['daddress1']);
$daddress2=mysql_real_escape_string($_POST['daddress2']);
$dcity=mysql_real_escape_string($_POST['dcity']);
$dstate=mysql_real_escape_string($_POST['dstate']);
$dzip=mysql_real_escape_string($_POST['dzip']);
$phone=mysql_real_escape_string($_POST['phone']);
$fax=mysql_real_escape_string($_POST['fax']);
$proof=mysql_real_escape_string($_POST['proof']);
$whoproof=mysql_real_escape_string($_POST['whoproof']);
$quote=mysql_real_escape_string($_POST['quote']);
$amount=mysql_real_escape_string($_POST['amount']);
$delivery=mysql_real_escape_string($_POST['delivery']);
$notes=mysql_real_escape_string($_POST['notes']);
$data = "UPDATE DB_Table SET drepid='$drepid', datepicker='$datepicker', repemail='$repemail', dateneeded='$dateneeded', description='$description', qty='$qty', pgsizeh='$pgsizeh', pgsizew='$pgsizew', pageno='$pageno', stock='$stock', ink='$ink', inknote='$inknote', rfq='$rfq', finishing='$finishing', dfirstname='$dfirstname', dlastname='$dlastname', dorganization='$dorganization', email='$email', daddress1='$daddress1', daddress2='$daddress2', dcity='$dcity', dstate='$dstate', dzip='$dzip', phone='$phone', fax='$fax', proof='$proof', whoproof='$whoproof', quote='$quote', amount='$amount', delivery='$delivery', notes='$notes' WHERE drfq=.$drfq";
$query = mysql_query($data) or die("Couldn't execute query\"$data\" Error:" . mysql_error());
?>