dimanche 28 février 2016

How do I search certain row based on checkboxes and other forms

I have this tiny problem that I have been trying to solve for days now and in my anger I deleted everything I had yesterday. Not a smart choice.

Well, I have around 10 checkboxes on my site and I would like to use them to search in a row and get 1 correct row and display it on another page.

This is the form on index.php

<form action="country.php" method="post">
What continent do you want to visit?
<br>
<select name="continent[]">
   <option value="Europe">Europe</option>
   <option value="North America">North America</option>
   <option value="South America">South America</option>
   <option value="Asia">Asia</option>
   <option value="Australia">Australia</option>
   <option value="Africa">Africa</option>
</select>
<br><br>
What do you want to experience?
<br>

<input type="checkbox" name="action[]" value="Action"> Action
<input type="checkbox" name="romance[]" value="Romance"> Romance
<input type="checkbox" name="snow[]" value="Snow"> Snow
<input type="checkbox" name="music[]" value="Music"> Music
<input type="checkbox" name="festival[]" value="Festival"> Festival
<input type="checkbox" name="child[]" value="Child"> Child-Proof
<br><br>

<input type="submit" value="Find!">

And I want the program to find a row that suits the checkboxes, I will add more checkboxes in the future but while I am making the site I decided to just keep it short and simple.

Then I made the SQL like this:

id  /  country  /  background  /  description  /  checkbox  / continent /
1      Iceland    img/ice.jpg   some description  action,snow  europe
2      Denmark    img/den.jpg   some description  festival     europe

And I am looking for a way so when I click on find the program runs through my DB and finds the row which is best suited.

If I check in Action and Snow and choose Europe I will get Iceland on country.php or if I check festival and choose Europe I will get Denmark.

I have googled everything to the point of not knowing what I should google. Can someone please help me. I bet this is pretty simple but I'm not getting it!




Aucun commentaire:

Enregistrer un commentaire