I am trying to filter out a MYSQL table according to user selected values in my php file list.php
My table users have field stdYr, in which elements have values of S00, S01, ... S40.
in html body, I have this chunk of code:
<form method="post" role="form" action="list.php">
<div>
<select multiple>
<option value="all">Select</option>
<option value="S00">74</option>
<option value="S01">75</option>
<option value="S02">76</option>
...
<option value="S40">114/option>
</select>
<button type="submit"></button>
</div>
</form>
And then, I want to select those with selected stdYr values.
The approach I could come up with is passing the values of option through $_POST:
if(isset($_POST['S00']) || isset($_POST['S11']) || ...
... || isset($_POST['S40'])) {
/*some code to get only those set values*/
$query="SELECT * FROM users WHERE stdYR = '/*some stuff*/'";
}
But with different possible selections of values, I couldn't figure out how exactly to do this... And even with the solution, I see this approach very repetitive and silly. How am I supposed to deal with such things?
I greatly appreciate your help! Thanks :D
name=""to<select multiple>at first. yourifstatement doesn't make sense.