我如何重新加载URL链接,在我点击提交按钮后它保持不变


How can I reloaded URL link, that it stay the same after I click on submit button

我有一个简单的形式:

    <div class="form-style-2">
    <form action="" name="formular" id="formular" method="GET">
    <label for="actual_position"><span>From: <span class="required"></span></span><input name="actual_position" type="text" maxlength="512" id="actual_position" class="searchField" 
                                        <?php if(!empty($actual_position)){  ?>
                                                  value="<?php echo $_GET['actual_position']?>"
                                                <?php
                                                }else {
                                                  ?> value = ""; <?php
                                                      }  ?>/></label>
    <label for="final_position"><span>To: <span class="required"></span></span><input name="final_position" type="text" maxlength="512" id="final_position" class="searchField"     <?php if(!empty($final_position)){  ?>
                                                  value="<?php echo $_GET['final_position']?>"
                                                <?php
                                                }else {
                                                  ?> value = ""; <?php
                                                      }  ?>/></label>
<input type="submit" value="Find path" />

表单中的另一个多选从url链接中获取值,并与数据库进行比较,得到一些结果。这是一个代码:

<table  width= "570px">  
    <tr><td width="200px" style="align:center"><b>Waypoints:</b> <br>
    <tr><td width="370px"><select style="float:center; margin-left:5px" multiple id="waypoints">
        if(!empty($urls)){
            foreach($urls as $url){
                if($result = $conn->query("SELECT * FROM $table where $ID = '$url' "));
                    $atraction = $result->fetch_array();  ?>
                        <option value="<?php echo  $atraction['lat']. "," . $atraction['lon']; ?>" 
                        > <?php  echo  "<b>".$atrction['City']. ", " . $atraction['Name'];?> </option>
    <?php         
            }
        }
    ?>                                         
                      </select></td></tr>
    <br>
</table>
</form>

从url代码中获取ID-s:

if(!empty($_GET[$ID])){
$urls = $_GET[$ID];
  foreach($urls as $url){ 
 //  echo $url;
  }
}

提交后,它会将一些变量发布到URL,如下所示:http://127.0.0.1/responsiveweb/travel.php?actual_position=Paris&final_position=Praha&ID[]=23&ID[]=15&ID[]=55

对我来说非常重要的是ID-s值。。。但当我改变实际位置,然后提交时,我丢失了ID-s,我得到了这样的东西:http://127.0.0.1/responsiveweb/travel.php?actual_position=Berlin&final_position=Praha

你能帮我点击提交按钮后如何获得完整的url链接吗?感谢

我很难理解你的问题OP,但我想我不知怎么理解了你的意思,所以我决定试着给你一个答案。

我重新编写了您的代码,并试图以某种方式改进代码结构。我在示例中还使用了表单方法POST,因此您可以看到如何更改重定向url上的get数据。

请在此处查看我的代码示例:http://pastebin.com/wQ7QCBmt

我还决定使用表单方法POST而不是GET,这样您就可以轻松地执行后端任务,并在必要时扩展链接。即使使用GET,您也可以向链接添加更多数据。您可以在表单中添加隐藏的输入,例如:

<input type="hidden" name="more_data" value="a_value" />