日期:2014-05-16  浏览次数:20574 次

修改程序 用户没有修改数据时不更新txt文件
再退回首页前,用户无论是否修改数据都要点保存,我设置了js提示,但是万一点错,数据就全没了,我想只在文件里写入修改的数据,若是判断数组的该值为空则不执行fwrite,但是行不通,求大牛之指教
<?php
error_reporting(4);
?>
<div>
<table id="AAP">
<form action="tableAAP.php" method="post">
<thead>
</thead>
<tbody id="content">
<tr>
<th>Segment</th>
<th>Function</th>
<th>2014&nbsp </th>
<th>2015&nbsp </th>
<th>2016&nbsp </th>
<th>2017&nbsp </th>
<th>2018&nbsp </th>
</tr>
<?php
$filename="AAPvaleurs.txt";
$file_hwnd=fopen($filename,"r");
$content = fread($file_hwnd, filesize($filename));  
fclose($file_hwnd);
$AAP2 = unserialize($content); 
?>
<tr class="premium">
<td class="premium">Premium</td>
<td class="productline">Product Line</td>
<td><input type="text" class="edit" id="PP11" name="PP11" required="" value=<?php echo $AAP2[0]?> ></td>
<td><input type="text" class="edit" id="PP12" name="PP12" required="" value=<?php echo $AAP2[1]?> ></td>
<td><input type="text" class="edit" id="PP13" name="PP13" required="" value=<?php echo $AAP2[2]?> ></td>
<td><input type="text" class="edit" id="PP14" name="PP14" required="" value=<?php echo $AAP2[3]?> ></td>
<td><input type="text" class="edit" id="PP15" name="PP15" required="" value=<?php echo $AAP2[4]?> ></td>
</tr>


<tr class="premium">
<td class="premium">Premium</td>
<td class="design">Design</td>
<td><input type="text" class="edit" id="PD11" name="PD11" required="" value=<?php echo $AAP2[5]?> ></td>
<td><input type="text" class="edit" id="PD12" name="PD12" required="" value=<?php echo $AAP2[6]?> ></td>
<td><input type="text" class="edit" id="PD13" name="PD13" required="" value=<?php echo $AAP2[7]?> ></td>
<td><input type="text" class="edit" id="PD14" name="PD14" required="" value=<?php echo $AAP2[8]?> ></td>
<td><input type="text" class="edit" id="PD15" name="PD15" required="" value=<?php echo $AAP2[9]?> ></td>
</tr>



<tr class="value">
<td class="value">Value</td>
<td class="technologyeng">Technology Eng</td>
<td><input type="text" class="edit" id="VT11" name="VT11" required="" value=<?php echo $AAP2[40]?> ></td>
<td><input type="text" class="edit" id="VT12" name="VT12" required="" value=<?php echo $AAP2[41]?> ></td>
<td><input type="text" class="edit" id="VT13" name="VT13" required="" value=<?php echo $AAP2[42]?> ></td>
<td><input type="text" class="edit" id="VT14" name="VT14" required=""&nb