// 私は 3 つの .php を持っています。コードはエラーを出しませんが、データを変更しません。1 つ目は edit.php で、次のコードは次のとおりです。
<?php
include"db.php";//database connection
/*$result = mysql_query("SELECT * FROM inward ");
$row = mysql_fetch_array($result);*/
$order = "SELECT * FROM inward";
$result = mysql_query($order);
while ($row=mysql_fetch_array($result))
{
$inwardid = $row['inwardID'];
echo "<tr align='center'>";
echo"<td><font color='black'>" .$row['inwardID']."</font></td>";
echo"<td><font color='black'>" .$row['inreceiptno']."</font></td>";
echo"<td><font color='black'>". $row['inreceiptdt']. "</font></td>";
echo"<td><font color='black'>". $row['sendername']. "</font></td>";
echo"<td><font color='black'>". $row['senderaddress']. "</font></td>";
echo"<td><font color='black'>" .$row['insubject']."</font></td>";
echo"<td><font color='black'>" .$row['inacceptedby']."</font></td>";
echo"<td><font color='black'>" .$row['inreceiptmode']."</font></td>";
echo"<td><font color='black'>" .$row['remark']."</font></td>";
echo"<td><font color='black'>" .$row['person']."</font></td>";
echo"<td><font color='black'>" .$row['duedate']."</font></td>";
echo"<td><font color='black'>" .$row['compliancemode']."</font></td>";
echo"<td><font color='black'>" .$row['adreceiptdate']."</font></td>";
echo"<td><font color='black'>" .$row['filename']."</font></td>";
echo ("<td><a href=\"edit_form.php?id=".$row['inwardID']."\">Edit</a></td></tr>");
}
?>
// 私の 2 番目のファイル名は edit_form.php です。ソースコードは次のとおりです。
<?php
include "db.php";//database connection
$id = $_GET["id"];
/* $result = mysql_query("SELECT * FROM inward WHERE inwardID='$id'");
$row = mysql_fetch_array($result);*/
$order = "SELECT * FROM inward
where inwardID='$id'";
$result = mysql_query($order);
$row = mysql_fetch_array($result);
?>
<form method="post" action="edit_data.php">
<input type="hidden" name="id" value="<?php echo $row['inwardID']; ?>">
<tr>
<td>Receipt No</td>
<td>
<input type="text" name="inreceiptno" size="20" value="<?php echo "$row[inreceiptno]"?>">
</td>
</tr>
<tr>
<td>Receipt Date</td>
<td>
<input type="text" name="inreceiptdt" size="40" value="<?php echo "$row[inreceiptdt]"?>">
</td>
</tr>
<tr>
<td>Sender Name</td>
<td>
<input type="text" name="sendername" size="40" value="<?php echo "$row[sendername]"?>">
</td>
</tr>
<tr>
<td>Sender Address</td>
<td>
<input type="text" name="senderaddress" size="40" value="<?php echo "$row[senderaddress]"?>">
</td>
</tr>
<tr>
<td>Subject</td>
<td>
<input type="text" name="insubject" size="40" value="<?php echo "$row[insubject]"?>">
</td>
</tr>
<tr>
<td>Accepted by</td>
<td>
<input type="text" name="inacceptedby" size="40" value="<?php echo "$row[inacceptedby]"?>">
</td>
</tr>
<tr>
<td>Receipt Mode</td>
<td>
<input type="text" name="inreceiptmode" size="40" value="<?php echo "$row[inreceiptmode]"?>">
</td>
</tr>
<tr>
<td>Remark For Action</td>
<td>
<input type="text" name="remark" size="40" value="<?php echo "$row[remark]"?>">
</td>
</tr>
<tr>
<td>Responsible Person</td>
<td>
<input type="text" name="person" size="40" value="<?php echo "$row[person]"?>">
</td>
</tr>
<tr>
<td>Compliance Due Date</td>
<td>
<input type="text" name="duedate" size="40" value="<?php echo "$row[duedate]"?>">
</td>
</tr>
<tr>
<td>Mode of Compliance Sent</td>
<td>
<input type="text" name="compliancemode" size="40" value="<?php echo "$row[compliancemode]"?>">
</td>
</tr>
<tr>
<td>Date of A.D.receipt ( If A.D.)</td>
<td>
<input type="text" name="adreceiptdate" size="40" value="<?php echo "$row[adreceiptdate]"?>">
</td>
</tr>
<tr>
<td>Name of the file for record</td>
<td>
<input type="text" name="filename" size="40" value="<?php echo "$row[filename]"?>">
</td>
</tr>
<tr>
<td align="right"> <input name="submit" type="submit" value="save">
</td>
</tr>
</form>
</table>
</td>
</tr>
</table>
//私の 3 番目のファイルは edit_data.php です。コードは次のとおりです。
include "db.php";
if(isset($_POST['save']))
{
$inreceiptno= $_POST['inreceiptno'] ;
$inreceiptdt=$_POST['inreceiptdt'] ;
$sendername=$_POST['sendername'] ;
$senderaddress=$_POST['senderaddress'] ;
$insubject=$_POST['insubject'] ;
$inacceptedby=$_POST['inacceptedby'] ;
$inreceiptmode=$_POST['inreceiptmode'] ;
$remark=$_POST['remark'];
$person=$_POST['person'];
$duedate=$_POST['duedate'];
$compliancemode=$_POST['compliancemode'];
$adreceiptdate=$_POST['adreceiptdate'];
$filename=$_POST['filename'];
$order= "UPDATE inward SET inreceiptno='$inreceiptno',
inreceiptdt='$inreceiptdt',
sendername='$sendername',
senderaddress='$senderaddress',
insubject='$insubject',
inacceptedby='$inacceptedby',
inreceiptmode='$inreceiptmode',
remark='$remark',
person='$person',
duedate='$duedate',
compliancemode='$compliancemode',
adreceiptdate='$adreceiptdate',
filename='$filename'
WHERE inwardID='$id'";
}
}
mysql_query($order);
header("location:edit.php");
?>