我正在使用脚本通过 mySQL 中的 php 更新我的记录。除了 $part_no 之外的所有字段都可以更新。
我不明白为什么“part_no”不会更新。
感谢任何帮助。
<?php session_start();
$type=$_POST['type'];
$part_no=$_POST['part_no'];
$description=$_POST['description'];
$artwork=$_POST['artwork'];
$min=$_POST['min'];
$max=$_POST['max'];
$db="naturan8_hero";
$link = mysql_connect("localhost", "XXXXXXX", "XXXXXX");
if (! $link)
die("Couldn't connect to MySQL");
mysql_select_db($db , $link)
or die("Couldn't open $db: ".mysql_error());
$query = mysql_query(" UPDATE cartons_current SET type='$type' , part_no='$part_no', description='$description',artwork='$artwork', min='$min' , max='$max' WHERE part_no='$part_no' ");
if($query) {
header("location: inv_fc_edit_success.php?part_no=" . urlencode($part_no));
}else{
header("location: inv_fc_edit_fail.php");
}
?>
以下是编辑表格:
<?php
$record = $_POST['part_no'];
mysql_connect("$host", "$username", "$password") or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$result=mysql_query(" SELECT * FROM cartons_current WHERE part_no='$record'");
$num=mysql_num_rows($result);
$i=0;
while ($i < $num) {
$type=mysql_result($result,$i,"type");
$part_no=mysql_result($result,$i,"part_no");
$description=mysql_result($result,$i,"description");
$artwork=mysql_result($result,$i,"artwork");
$min=mysql_result($result,$i,"min");
$max=mysql_result($result,$i,"max");
?>
<div id="fcICON">Hero</div>
<div id="titleWRAP">
<div id="newTITLE">Edit Part Number</div>
<div id="newINS">This area is designated for editing a part number. Please <b>be careful and alert </b>to your changes, because they are immediately posted.</div>
</div>
<div class="form_hero_new">
<form id="form_editX" method="POST" action="inv_fc_edit2.php" onfocus="this.value=''">
<input type="hidden" name="type" type="text" value="FC">
<input type="hidden" name="part_no" value="<? echo "$record" ?>">
<div style="width: 500px; height:63px;float:left;">
<div style="width: 165px; height:65px;float:left;">
<div id="heroLABEL" style="width:150px">Part Number</div>
<div id="newPN">
<textarea name="part_no" maxlength="20" minlength="6" type="text" style="width: 130px;color:#FFFF00"><? echo "$part_no"?></textarea>
</div>