I am working on a checkbox search. I'm new to PHP. I would appreciate it if someone could help me. Basically the user checks the options required, hits submit and results matching the checkbox options is displayed. The checkboxes have a value of M for Male and F for Female which matches the data in the MYSQL table.
So if a user checks checkbox 'Male' (see code below) all data with 'Male' that have a value of 'M' in the MYSQL table are returned. And any checkboxes not checked should simply be ignored as the user is only interested in the option 'Male' being 'M' (true).
To sum up I only need the search to take into account checkboxes that have been checked and echo which users that has been selected(more like filtering) through PHP.Any help appreciated. Thanks
the table looks like this :
id name address gender race
-------------------------------------------
1. 1 Lee NY M French
2. 2 James LA M Colombian
3. 3 Kashi JAPAN F Japanese
and i have a form with checkboxes like this :
<form action="shortlist.php" method="post">
Search: <input name="searchquery" type="text">
<button name = "myBtn" type="submit" class="btn btn-default">Search</button>
<br/><br/>
<label for="sel1">Shortlist:</label>
<select name = "filter" class="form-control" id="sel1">
<option value="Race">Race</option>
<option value="Gender">Gender</option>
<option value="Age">Age</option>
<option value="Skills">Skills</option>
</select>
</form>
Aucun commentaire:
Enregistrer un commentaire