lundi 16 février 2015

Multiple Choice Results

Hi i have the following problem:


$result1 = 'Produkt 1'; (contains in database: option1 = A, option2 = '')


$result2 = 'Produkt 2'; (contains in database: option1 = ABS, option2 = '1F')


$result3 = 'Produkt 3'; (contains in database: option1 = FP, option2 = 'F')


Now i have a formsearch with checkboxes for the options, and i want only the results that are checked:





<input name="asia" type="checkbox" id="asia" value="A" />
<input name="bio" type="checkbox" id="bio" value="B" />
<input name="break" type="checkbox" id="break" value="F" />
<input name="piz" type="checkbox" id="piz" value="P" />
<input name="south" type="checkbox" id="south" value="S" />

<input name="glut" type="checkbox" id="glut" value="1" />
<input name="lak" type="checkbox" id="lak" value="F" />



if ($_POST of all checkboxes == ''){echo all results}


if ($_POST['asia']!=''){echo only results with A in option1}


if ($_POST['asia']!='' && $POST['bio']!=''){echo only results with A and B in option1}


if ($_POST['break']!='' && $POST['piz']!='' && $POST['lak']!=''){echo only results with F and P in option1 and F in option2}


I need always the products that compare with all selected checkboxes.


I know that i can make for every possibility a if or elseif, but is there a faster way e.g. with arrays


Thanks a lot for every suggestion





Aucun commentaire:

Enregistrer un commentaire