我正在尝试从表上显示的用户输入更新mysql数据,我使用了以下代码,即使设置了名称并且在我单击更新代码状态时设置了值"未定义索引: LHA"但正如你所看到的,我已经将它与Work_date,LHA,AAS,LSA,AAH(抛出不应对的索引错误的字段)一起声明了这一点我还希望unefcted数据在mysql数据库中保持相同,并将其设置为空白!这是HTML(一个while语句,用于获取数据以填充html表中的值字段)
while($row = $sth->fetch()) { ?>
<form action='../action.php' method='post'>
<tr>
<td> <?php echo $row['Name'] ?></td>
<td> <input name='car' id='car' value="vv1"><br/><br/></td>
<td> <select name='Night' id='Night'><option selected='selected' value='no'>No</option><option value='Yes'>Yes</option></select> <br/><br/></td>
<td> <input class='text' name="Siteid" type="text" value="<?php echo $row['Workbook ID']; ?>" /> <br/><br/></td>
<td> <input class='datepicker' name="Work_date" type="text" value="<?php echo date('l, F d, Y', strtotime($row['Work Date'])) ?>" placeholder="Select Date!"/><br/><br/></td>
<td> <input class='timepicker' name="LHA" type="text" value="<?php echo $row['LHA'] ?>" /><br/><br/></td>
<td> <input class='timepicker' name="AAS" type="text" value="<?php echo $row['AAS'] ?>" /><br/><br/></td>
<td> <input class='timepicker' name="LSA" type="text" value="<?php echo $row['LS'] ?>" /><br/><br/></td>
<td> <input class='timepicker' name="AAH" type="text" value="<?php echo $row['AAH'] ?>" /><br/><br/></td>
<td> <input name="Bonus" type="text" value="<?php echo $row['Bonus']; ?>" /> <br/><br/></td>
<td> <input name="Work_Completed" type="text" value="<?php echo $row['Work Completed']; ?>" /> <br/><br/></td>
<td> <input name="BH" type="text" value="<?php echo $row['Hours']; ?>" /><br/><br/></td>
<input type='hidden' name='PID' value="<?php echo $row['PID'];?>" />
<td><input type='submit' name='delete_timesheet' value='delete' /></td>
<td><input type='submit' class='btn btn-default' name='update_timesheet' value='Update' /></td>
</tr>
</form>
<?php
}
只是提到我的查询和字段设置在XAMPP上完美运行但在线时没有,这是我的PHP
if(isset($_POST['update_timesheet'])) {
$a = $_POST['car'];
$b = $_POST['Night'];
$c = $_POST['Siteid'];
$d = $_POST['Work_date'];
$e = $_POST['LHA'];
$f = $_POST['AAS'];
$g = $_POST['LSA'];
$h = $_POST['AAH'];
$i = $_POST['Bonus'];
$j = $_POST['BH'];
$l = $_POST['PID'];
$Paid = create_paid($e, $f, $g, $h);
$stmt = "UPDATE data SET Car = ?, Night = ?, `Workbook ID` = ?, `Work Date` = ?, LHA = ?, AAS = ? , LS = ? , AAH = ? , Bonus = ?, `Work Completed` = ?, Hours = ? WHERE PID = ? ";
$y = $pdo->prepare($stmt);
$y->execute(array($a,$b, $c, $d, $e, $f, $g, $h, $i, $j, $Paid, $l));
header('Location: ' . $_SERVER['HTTP_REFERER']);
}