我发送表格并显示留言板,它仅显示selecta和Submita的内容,其余为空。将输入值放在文件中时,在发送后显示它。我将在网站上手动输入游戏,但不会。我还编写了这段代码,以便修改数据库中的数据,但是由于这个错误,我不知道为什么这样做以及如何开发它。我从来没有发生过这种情况。因为我在代码中看不到任何错误。
MySQL 5,PHP5,HTML5,CSS3
<div class="limiter">
<div class="container-table100">
<div class="wrap-table100">
<div class="table100">
<?php
$type = "djs";
$event = "Halloween Night";
$message = '<span class="warning">Brak Danych!</span>';
$sql = $pdo->prepare($select['list']);
$sql->execute([
$select['event']=> $event,
$select['type']=> $type
]);
$rows = $sql->fetchAll(PDO::FETCH_ASSOC);
$i = 1;
echo('<form id="form-v2" action="" method="POST"><table><thead>
<tr class="table100-head">
<th class="column1">#</th>
<th class="column2">DJ</th>
<th class="column3">FanPage</th>
<th class="column41">E-Mail</th>
<th class="column52">Status</th>
<th class="column6">Zatwierdź</th>
</tr>
</thead><tbody>');
if($sql->rowCount()>0){
foreach($rows as $row){
if($row['status']=="accept"){
$status = 'Zatwierdzony';
}else if($row['status']=="deny"){
$status = 'Odrzucony';
}else{
$status = 'Nie Zatwierdzony';
}
echo('<tr>
<td class="column1">'.$i.'</td>
<td class="column2"><input class="col3 dl" type="text" id="dj" name="dj" value="'.$row['dj'].'" placeholder="'.$row['dj'].'"></td>
<td class="column3"><input class="col3 dl" type="text" id="facebook" name="facebook" value="'.$row['facebook'].'" placeholder="'.$row['facebook'].'"></td>
<td class="column41"><input class="col3 dl" type="text" id="email" name="email" value="'.$row['e-mail'].'" placeholder="'.$row['e-mail'].'"></td>
<td class="column52"><div class="box">
<select name="status" id="status">
<option value="'.$row['status'].'" selected disabled>'.$status.'</option>
<option value="accept">Zatwierdzony</option>
<option value="deny">Odrzucony</option>
<option value="">Nie Zatwierdzony</option>
</select>
</div></td>
<td class="column61"><button class="btn btn-5 btn-sep icon-save" type="submit" id="code" name="code" value="'.$row['code'].'">Zapisz</button></td>
</tr></tr>');
$i++;
}
}else{
echo('<tr>
<td class="column1">'.$i.'</td>
<td class="column2">'.$message.'</td>
<td class="column3">'.$message.'</td>
<td class="column4">'.$message.'</td>
<td class="column5">'.$message.'</td>
<td class="column6">'.$message.'</td>
</tr></tr>');
}
echo("</tbody></table></form>");
$sql = $pdo->prepare($select['list']);
$sql->execute([
$select['event']=> $event,
$select['type']=> $type
]);
$rows = $sql->fetchAll(PDO::FETCH_ASSOC);
//var_dump($_POST);
foreach($rows as $row){
if($_SERVER['REQUEST_METHOD']=="POST"){
if($_POST['code']==$row['code']&&isset($_POST['code'])){
var_dump($_POST['facebook']);
/*
$sql = $pdo->prepare($update['edit']);
$sql->execute([
$update['dj']=> $_POST['dj'],
$update['facebook']=> $_POST['facebook'],
$update['e-mail']=> $_POST['email'],
$update['action']=> $_POST['status'],
$update['event']=> $event,
$update['code']=> $_POST['code']
]);
echo('<div class="alert success">
<span class="closebtn">×</span>
<strong>Success!</strong> Pomyślnie Edytowano Profil DJ'."'a.
</div>");
*/
}else{
echo('<div class="alert">
<span class="closebtn">×</span>
<strong>Upsss!</strong> Wystąpił Błąd.
</div>');
}
}
}
echo('
<script>
var close = document.getElementsByClassName("closebtn");
var i;
for (i = 0; i < close.length; i++) {
close[i].onclick = function(){
var div = this.parentElement;
div.style.opacity = "0";
setTimeout(function(){ div.style.display = "none"; }, 600);
}
}
</script>');
?>
</div>
</div>
</div>
</div>
@(Html.Kendo().Grid<ScheduleViewModel>()
.Name("ScheduleGrid")
.AutoBind(true)
-
)
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Columns(columns =>
{
columns.Bound(s => s.Name).Title("Schedule").Filterable(true).Width(150).HtmlAttributes(new { style = "text-align: left" });
columns.Bound(s => s.StartTime).Width(100).Title("Start Time").ClientTemplate((
@Html.Kendo().DatePicker()
.Name("StartTimePicker")
.Value("#=StartTime#")
//.Format("{0:dd/MM/yyyy}")
.ToClientTemplate()).ToHtmlString());
columns.Bound(s => s.Enabled).Width(100).ClientTemplate("<input type='checkbox' #=Enabled ? checked='checked' : '' # class='sda-checkbox' />").HtmlAttributes(new { @class = "text-center" });
columns.Command(command => command.Custom("Save").Click("saveSchedules")).Width(80).HtmlAttributes(new { @class = "text-center" });
})
答案 0 :(得分:0)
您在表的每一行上使用相同的名称作为输入。但是只能有一个具有特定名称的POST
变量。它将从表的最后一行获取值,而不是您使用其提交按钮的值。
给出输入数组样式名称。然后它将在POST
变量中创建一个值数组。
echo('<tr>
<td class="column1">'.$i.'</td>
<td class="column2"><input class="col3 dl" type="text" id="dj" name="dj['.$row['code'].']" value="'.$row['dj'].'" placeholder="'.$row['dj'].'"></td>
<td class="column3"><input class="col3 dl" type="text" id="facebook" name="facebook['.$row['code'].']" value="'.$row['facebook'].'" placeholder="'.$row['facebook'].'"></td>
<td class="column41"><input class="col3 dl" type="text" id="email" name="email['.$row['code'].']" value="'.$row['e-mail'].'" placeholder="'.$row['e-mail'].'"></td>
<td class="column52"><div class="box">
<select name="status['.$row['code'].']" id="status">
<option value="'.$row['status'].'" selected disabled>'.$status.'</option>
<option value="accept">Zatwierdzony</option>
<option value="deny">Odrzucony</option>
<option value="">Nie Zatwierdzony</option>
</select>
</div></td>
<td class="column61"><button class="btn btn-5 btn-sep icon-save" type="submit" id="code" name="code" value="'.$row['code'].'">Zapisz</button></td>
</tr></tr>');
然后您可以像这样处理表格:
$code = $_POST['code'];
$dj = $_POST['dj'][$code];
$facebook = $_POST['facebook'][$code];
// and so on