0

所以我有一个搜索表单,当搜索结果页面加载时,顶部有一些跳转菜单,允许用户缩小结果范围。

跳转菜单显示从已发布表单中选择的搜索条件。

但是,在“端口”跳转菜单中,如果您选择布里斯托尔或爱丁堡,当您进入结果页面时,端口菜单不会将它们显示为选中状态。它适用于所有其他人......

这是我在游轮搜索框中的搜索选择代码

<select name="port" id="port">
<option selected value="%">All Ports...</option>
<option value="Bristol Avonmouth">Bristol Avonmouth</option>
<option value="Edinburgh Leith">Edinburgh Leith</option>
<option value="Glasgow Greenock">Greenock</option>
<option value="Hull">Hull</option>
<option value="Liverpool">Liverpool</option>
<option value="London, Tilbury">London Tilbury</option>
<option value="Newcastle">Newcastle</option>
</select>

这是结果页面上的跳转菜单代码

<div id="cac">
    <h3>Sailing from...</h3>
    <p>&nbsp;</p>
    <p>
    <select name="jumpMenu3" id="jumpMenu3" onchange="MM_jumpMenu('parent',this,0)">
    <option value="">Select a port</option>
    <?php
    $ports = array(); 
    mysql_data_seek($cruises, 0);
    while ($row_cruises = mysql_fetch_assoc($cruises)) { 
    if (!in_array($row_cruises['fromport'], $ports)) {
        $ports[] = $row_cruises['fromport'];
    ?>
    <option value="index.php?subj=2&destination=<?php echo urlencode($row_cruises['destination']);?>&departs=<?php echo date('Ym',strtotime($row_cruises['departs']));?>&port=<?php echo urlencode($row_cruises['fromport']);?>"<?php if ($_GET['port'] == $row_cruises['fromport'] OR $_POST['port'] == $row_cruises['fromport']) {echo "selected=\"selected\"";}?>><?php echo $row_cruises['fromport']; ?></option>
    <?php } ;
    }
    if(mysql_num_rows($cruises) > 0) {
        mysql_data_seek($cruises, 0);
        $row_cruises = mysql_fetch_assoc($cruises);
    }
    ?>
    </select>

我已经在数据库中检查了端口本身的拼写、大小写、间距……一切都很好。

也许我需要一个类似或通配符比较运算符?

嘟嘟嘟

已修复 - 端口查找不是针对端口表,而是针对邮轮表中为出发港口编写的内容,并且有一些邮轮输入错误...

富有的 :)

4

1 回答 1

0

尝试替换
if ($_GET['port'] == $row_cruises['fromport'] OR $_POST['port'] == $row_cruises['fromport'])

if ($_GET['port'] == urlencode($row_cruises['fromport']) OR $_POST['port'] == urlencode($row_cruises['fromport']))

于 2012-05-11T09:49:11.710 回答