0

我有一个用于搜索查询的复选框功能。我的问题是我搜索时创建的网址。

?ct_zipcode=&ct_event_type=birthday&ct_event_type=photovideo-shoot&Venue-search=true

当我检查了多个分类名称时,我只会在搜索结果中得到最后一个条目。

我需要像这样重写我的网址:

?ct_zipcode=&ct_event_type=birthday%2Cphotovideo-shoot&Venue-search=true 

有没有一种简单的方法可以通过重写来更改我的网址?我尝试了一点str_replace/preg_replace没有运气。

4

1 回答 1

0

将输入字段的名称更改为ct_event_type[],您将获得检查值作为数组。


HTML 部分应如下所示:

<div>
    <label for="ct_<?php echo $name; ?>"> // for should be the same as checkbox id
        <input
          id="ct_<?php echo $name; ?>"
          name="ct_<?php echo $name; ?>"
          type="checkbox"
          style="margin-right:5px; margin-left:5px"
          value="<?php echo $t->slug; ?>" />   // <-- closing input
        <?php echo $t->name; ?>
    </label>
</div>

注意使用label.

于 2013-02-25T16:16:40.620 回答