PHP/HTML-更多回音';表1中的s

PHP/HTML-更多回音';表1中的s,php,html,Php,Html,我需要一些帮助,我编写了这个代码,当有人填写表单时,他们填写的名字必须写入表中 因此,如果有人在名称字段中键入:“Jay Adamsen”。并选中“栏”,然后选择“10:00-11:00”,表单将把它写到正确的位置。这很好:) 但当另一个人在姓名字段中键入:“Jack Carlson”并选中“Bar”,然后选择“11:00-12:00”时,代码将删除“Jay Adamsen”,并将新姓名写入右侧框中。 这是我的代码: <?php $navn = $_REQUEST['na

我需要一些帮助,我编写了这个代码,当有人填写表单时,他们填写的名字必须写入表中

因此,如果有人在名称字段中键入:“Jay Adamsen”。并选中“栏”,然后选择“10:00-11:00”,表单将把它写到正确的位置。这很好:)

但当另一个人在姓名字段中键入:“Jack Carlson”并选中“Bar”,然后选择“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" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>

身体{
宽度:950px;
左边距:自动;
右边距:自动;
}
#横幅{
宽度:950px;
高度:200px;
左边距:自动;
右边距:自动;
边缘顶部:5px;
边缘底部:10px;
}
tekst先生{
文本对齐:居中;
}
.link1{
高度:50px;
宽度:237px;
浮动:左;
}
.link2{
高度:50px;
宽度:237px;
浮动:左;
}
.link3{
高度:50px;
宽度:237px;
浮动:左;
}
.link4{
高度:50px;
宽度:237px;
浮动:左;
}
#流浪汉{
浮动:左;
边缘顶部:10px;
背景色:#C3C;
宽度:950px;
}
.文本{
文本对齐:居中;
字号:38px;
}
表,th,td{
左边距:自动;
右边距:自动;
边框:1px纯黑;
背景色:#FF6;
边缘底部:10px;
}
.表格{
左边距:35px;
宽度:100%;
}
犹太人区聚会
Vagtplan

潮水 酒吧 因德冈 10:00 - 11:00 11:00 - 12:00 12:00 - 13:00 13:00 - 14:00 14:00 - 15:00 导航:
酒吧:英德冈:
克洛肯: 10:00 - 11:00 11:00 - 12:00 12:00 - 13:00 13:00 - 14:00 14:00 - 15:00

这是标准功能。如果要保存以前的条目,它们必须存储在服务器上的数据库或文本文件中。

当您重新输入名称时,它会刷新页面,从而丢失该页面上以前的值。您可以使用数据库存储值或创建xml或json文件,也可以在会话中存储值


另一个选项是使用AJAX,然后您可以提交而不丢失以前的值。

保留一个临时变量以在表中打印值,因为它每次都在更改。

    **Here is my Code:**

    <?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") {    
                                $navn_bar_10 = $navn;
                                print $navn_bar_10;      
                                }        
                                ?>
                            </center>
                        </td>
                        <td>
                            <center>
                                <?php  
                                if ($bar == "indgang" && $tidspunkt == "10:00") {   
                                $navn_indgang_10 = $navn;
                                print $navn_indgang_10;      
                                }        
                                ?></center>
                        </td>
                    </tr>
                    <tr>
                        <th scope="row">11:00 - 12:00</th>
                        <td>        <center><?php  
                                if ($bar == "bar" && $tidspunkt == "11:00") {  
                                $navn_bar_11 = $navn;        
                                echo $navn_bar_11;      
                                }        
                                ?></center></td>
                        <td>        <center><?php  
                                if ($bar == "indgang" && $tidspunkt == "11:00") {          
                                $navn_indgang_11 = $navn;
                                echo $navn_indgang_11;      
                                }        
                                ?></center></td>
                    </tr>
                    <tr>
                        <th scope="row">12:00 - 13:00</th>
                        <td>        <center><?php  
                                if ($bar == "bar" && $tidspunkt == "12:00") {          
                                $navn_bar_12 = $navn;                
                                echo $navn_bar_12;      
                                }        
                                ?></center></td>
                        <td>        <center><?php  
                                if ($bar == "indgang" && $tidspunkt == "12:00") {          
                                $navn_indgang_12 = $navn;                 
                                echo $navn_indgang_12;      
                                }        
                                ?></center></td>
                    </tr>
                    <tr>
                        <th scope="row">13:00 - 14:00</th>
                        <td>        <center><?php  
                                if ($bar == "bar" && $tidspunkt == "13:00") {          
                                $navn_bar_13 = $navn;                 
                                echo $navn_bar_13;     
                                }        
                                ?></center></td>
                        <td>        <center><?php  
                                if ($bar == "indgang" && $tidspunkt == "13:00") {          
                                $navn_indgang_13 = $navn;                 
                                echo $navn_indgang_13;           
                                }        
                                ?></center></td>
                    </tr>
                    <tr>
                        <th scope="row">14:00 - 15:00</th>
                        <td>        <center><?php  
                                if ($bar == "bar" && $tidspunkt == "14:00") {          
                                $navn_bar_14 = $navn;                 
                                echo $navn_bar_14;         
                                }        
                                ?></center></td>
                        <td>        <center><?php  
                                if ($bar == "indgang" && $tidspunkt == "14:00") {          
                                $navn_indgang_14 = $navn;                 
                                echo $navn_indgang_14;         
                                }        
                                ?></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" />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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>
**这是我的代码:**
身体{
宽度:950px;
左边距:自动;
右边距:自动;
}
#横幅{
宽度:950px;
高度:200px;
左边距:自动;
右边距:自动;
边缘顶部:5px;
边缘底部:10px;
}
tekst先生{
文本对齐:居中;
}
.link1{
高度:50px;
宽度:237px;
浮动:左;
}
.link2{
高度:50px;
宽度:237px;
浮动:左;
}
.link3{
高度:50px;
宽度:237px;
浮动:左;
}
.link4{
高度:50px;
宽度:237px;
浮动:左;
}
#流浪汉{
浮动:左;
边缘顶部:10px;
背景色:#C3C;
宽度:950px;
}
.文本{
文本对齐:居中;
字号:38px;
}
表,th,td{
左边距:自动;
右边距:自动;
边框:1px纯黑;
背景色:#FF6;
边缘底部:10px;
}
.表格{
左边距:35px;
宽度:100%;
}
犹太人区聚会
Vagtplan

潮水 酒吧 因德冈 10:00 - 11:00 11:00 - 12:00 12:00 - 13:00 13:00 -