我有10个记录和每个输入2个表。 我发表了它,并使用数组,但我做了一些错误,但无法弄清楚what.What我试图做的是更新多行时间! 我仍然在学习PHP数组阵列更新乘法结果出错
POST
if($source == 'hoursDayNight'){
$value = htmlentities($_POST['value'], ENT_QUOTES, "UTF-8");
$workcid = htmlentities($_POST['workcid'][$i], ENT_QUOTES, "UTF-8");
$worknight = htmlentities($_POST['worknight'][$i], ENT_QUOTES, "UTF-8");
$workday = htmlentities($_POST['workday'][$i], ENT_QUOTES, "UTF-8");
include('inc.php');
//$current_dateedit = date('Y-m-d == H:i:s');
$current_dateedit = date('Y-m-d');
$i=NULL;
$i=1;
$queryie = "UPDATE works SET workday='".$workday[$i]."', worknight='".$worknight[$i]."', type='1' WHERE id='" . $workcid[$i] . "'";
mysqli_query($conn, $queryie);
}
和表
<form name="hoursDayNight" method="POST" action="" >
<input type="hidden" name="source" value="hoursDayNight"/>
<table class="ui small sortable celled collapsing table">
<thead>
<tr>
<th>Worker</th>
<th>Day h</th>
<th>Night h</th>
</tr>
</thead>
<tbody>';
require('inc.php');
while ($row = mysqli_fetch_array($result)) {
$sql = "SELECT DISTINCT * FROM works WHERE worker = '".$row['person_code']."'";
$i=null;
$i++;
echo '<tr>
<input type="text" name="" disabled value="' . $row['worker'] . '">
<input type="hidden" name="workcid['.$i.']" value="' . $row['id'] . '">
<input type="text" style="width: 25px; border: 1px solid #C8CFD7; height: 16px; line-height:14px; text-align: center; font-size:10pt; color:#817e7f;" name="workday['.$i.']" value="' . $row['workday'] . '">
<td>
<input type="text" style="width: 25px; border: 1px solid #C8CFD7; height: 16px; line-height:14px; text-align: center; font-size:10pt; color:#817e7f;" name="worknight['.$i.']" value="' . $row['worknight'] . '">
</div>
</form>
这将是如果你确切地解释了问题所在,那么更容易帮助你。但我可以看到的一件事是,你明确地在你的代码中设置了'$ i = 1',所以它只会是那个得到更新的行。 – andrewsi
它不做任何事情。没有错误,没有数据保存 –
更具体。您的PHP代码是否被调用?如果是这样,请检查传递给它的参数是 - 它们应该是什么?添加一些调试到你的代码,看看你生成的查询是什么样子 - 他们看起来好吗?当你直接在数据库中尝试它们时,它们是否运行? – andrewsi