I have 2 multiple checkboxes and have problems to display it correct if more than one checkbox is ticked. Only the last checkbox get used for the filter in the Select query. I was searching a lot in the web, but I don't find someone who has also a problem with this.
HTML Code:
<aside><h3>Filter:</h3>
<details open="open">
<summary><label>Categorie</label></summary>
<div>
<label>
<input type="checkbox" name="filter_categorie[]" value="dog">
Dogs
</label>
</div>
<div>
<label>
<input type="checkbox" name="filter_categorie[]" value="fish">
Fishes
</label>
</div>
<div>
<label>
<input type="checkbox" name="filter_categorie[]" value="other">
Other
</label>
</div>
</details>
<details>
<summary><label>Land</label></summary>
<div>
<label>
<input type="checkbox" name="filter_country[]" value="germany">
Germany
</label>
</div>
<div>
<label>
<input type="checkbox" name="filter_country[]" value="austria">
Austria
</label>
</div>
</details>
<br><input type='submit' name ='update' value='Update'>
PHP Code:
include("server.inc");
$cxn = mysqli_connect($host,$user,$password,$database) or die ("No connection to Server");
if(isset($_POST['update']) ){
foreach ($_POST['filter_categorie[]'] as $item){
$query = "
SELECT *
FROM artikel
WHERE Categorie=\"{$_POST['filter_categorie']}\"
";}
$resultat = mysqli_query($cxn,$query) or die ("No results.");
Aucun commentaire:
Enregistrer un commentaire