我正在尝试使用复选框过滤产品,但是数组不断重复地址。如何避免这种情况?
这是我的表格
echo "Hello world\n";
这是动作文件代码
<form id="form" method="GET" action="<?php echo $MarkaSeoUrl; ?>" enctype="application/x-www-form-urlencoded">
<div class="custom-control custom-checkbox">
<span class="float-right badge badge-light round"><?php echo $SayiIcinMarkaSayisi; ?></span>
<input type="checkbox" class="custom-control-input" value="<?php echo $MarkaKayitlar["MarkaID"]; ?>" name="MarkaID[]" id="<?php echo $MarkaKayitlar["MarkaID"]; ?>"
<?php if(isset($_GET["MarkaID"])) {
if(in_array($MarkaKayitlar["MarkaID"], $FiltreIcinMarkaIdDizisi)){
echo "checked='checked'";
}
}
?>
>
<label class="custom-control-label" for="<?php echo $MarkaKayitlar["MarkaID"]; ?>"><?php echo DonusumleriGeriDondur($MarkaKayitlar["MarkaAdi"]); ?></label>
</div>
<!-- form-check.// -->
<?php } ?>
</form>
我的地址行看起来像这样,而且越来越长
if ( isset($_GET["MarkaID"]) ) {
$FiltreIcinMarkaIdDizisi = $_GET["MarkaID"];
if ( $FiltreIcinMarkaIdDizisi ) {
$FiltreIcinMarkaIdDizisiDuzenle = implode(',', $FiltreIcinMarkaIdDizisi);
}
$Marka = "AND MarkaID IN (" . $FiltreIcinMarkaIdDizisiDuzenle.")";
} else {
$Marka = "";
}
我希望它看起来像这样
http://localhost/E-Ticaret/kadin-giyim-c-15?MarkaID%5B%5D=2&MarkaID%5B%5D=3
我不知道该怎么做,你能帮我这个忙吗?
对不起,我的英语不好