我需要一些幫助,我做了這個代碼,當有人做表格時,他們填寫的名字必須寫入表格。PHP/HTML - 更多回聲的1表
因此,如果有人鍵入:「Jay Adamsen」在名稱字段中。並檢查「酒吧」然後選擇「10:00 - 11:00」然後窗體將它寫到正確的地方。和完美的作品:)
但是,當另一個人類型:「傑克·卡爾森」在名稱字段,並檢查「酒吧」,然後選擇「11:00 - 12:00」那麼代碼將刪除「Jay Adamsen」並將新名稱寫入右側框。
這裏是我的代碼:
<?php
$navn = $_REQUEST['navn'];
$bar = $_POST['barorindgang'];
$tidspunkt = $_POST['klokken'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
body {
width: 950px;
margin-left: auto;
margin-right: auto;
}
#Banner {
width: 950px;
height: 200px;
margin-left: auto;
margin-right: auto;
margin-top: 5px;
margin-bottom: 10px;
}
.tekst {
text-align: center;
}
.link1 {
height: 50px;
width: 237px;
float: left;
}
.link2 {
height: 50px;
width: 237px;
float: left;
}
.link3 {
height: 50px;
width: 237px;
float: left;
}
.link4 {
height: 50px;
width: 237px;
float: left;
}
#vagt {
float: left;
margin-top: 10px;
background-color: #C3C;
width: 950px;
}
.text {
text-align: center;
font-size: 38px;
}
table,th,td {
margin-left: auto;
margin-right: auto;
border: 1px solid black;
background-color: #FF6;
margin-bottom: 10px;
}
.form {
margin-left: 35px;
width: 100%;
}
</style>
<title>Ghetto Bash</title>
</head>
<body>
<div id="Banner">
<a href="index.html"><img src="pics/ghettobashbanner.jpg"></a>
</div>
<div id="bar">
<div class="link1"><a href="index.html"><img src="pics/forside.jpg"></a> </div>
<div class="link2"><a href="vagtplan.html"><img src="pics/vagtplan.jpg"></a> </div>
<div class="link3"><a href="billetter.html"><img src="pics/biletter.jpg"></a></div>
<div class="link4"><a href="billeder.html"><img src="pics/billeder.jpg"></a></div>
</div>
<div id="vagt">
<p class="text">Vagtplan</p>
<table width="93%" height="354" cellpadding="1">
<tr>
<th width="25%" scope="col">TIDER</th>
<th width="38%" scope="col">BAR</th>
<th width="37%" scope="col">INDGANG</th>
</tr>
<tr>
<th scope="row">10:00 - 11:00</th>
<td>
<center>
<?php
if ($bar == "bar" && $tidspunkt == "10:00") {
print $navn;
}
?>
</center>
</td>
<td>
<center>
<?php
if ($bar == "indgang" && $tidspunkt == "10:00") {
print $navn;
}
?></center>
</td>
</tr>
<tr>
<th scope="row">11:00 - 12:00</th>
<td> <center><?php
if ($bar == "bar" && $tidspunkt == "11:00") {
echo $navn;
}
?></center></td>
<td> <center><?php
if ($bar == "indgang" && $tidspunkt == "11:00") {
echo $navn;
}
?></center></td>
</tr>
<tr>
<th scope="row">12:00 - 13:00</th>
<td> <center><?php
if ($bar == "bar" && $tidspunkt == "12:00") {
echo $navn;
}
?></center></td>
<td> <center><?php
if ($bar == "indgang" && $tidspunkt == "12:00") {
echo $navn;
}
?></center></td>
</tr>
<tr>
<th scope="row">13:00 - 14:00</th>
<td> <center><?php
if ($bar == "bar" && $tidspunkt == "13:00") {
echo $navn;
}
?></center></td>
<td> <center><?php
if ($bar == "indgang" && $tidspunkt == "13:00") {
echo $navn;
}
?></center></td>
</tr>
<tr>
<th scope="row">14:00 - 15:00</th>
<td> <center><?php
if ($bar == "bar" && $tidspunkt == "14:00") {
echo $navn;
}
?></center></td>
<td> <center><?php
if ($bar == "indgang" && $tidspunkt == "14:00") {
echo $navn;
}
?></center></td>
</tr>
</table>
<center>
<form method="post" action="vagtplan.html">
Navn: <input type="text" name="navn" id="navn" required="required"/><br />
Bar: <input type="radio" name="barorindgang" value="bar" id="bar" required="required" /> Indgang: <input type="radio" name="barorindgang" value="indgang" id="indgang" required="required" /><br />
Klokken: <select name="klokken">
<option value="10:00">10:00 - 11:00</option>
<option value="11:00">11:00 - 12:00</option>
<option value="12:00">12:00 - 13:00</option>
<option value="13:00">13:00 - 14:00</option>
<option value="14:00">14:00 - 15:00</option>
</select>
<br />
<input type="submit" value="Send" />
</form>
</center>
</div>
</body>
</html>
這段代碼有什麼問題?什麼不行?你會得到什麼錯誤? –
當我在窗體中輸入另一個名字時,姓氏被刪除並放置新名字。我希望所有的名字都在那裏,所以如果有更多的人填寫表格,名字將顯示在表格中的所有黑色框中 – BechGameplay
@BechGameplay - 所以你想讓這兩個名字留在表格中?我對麼 ? – Hitesh