I am writing a search filter that will take a list of criteria, query the database, and return an array of usernames that match. Here is essentially what I'm doing:
if (!empty($_GET['cat'])) {
$category = urldecode($_GET['cat']);
$category_query = "SELECT DISTINCT username FROM tutor_subjects_taught WHERE category = '{$category}'";
$category_process = mysql_query($category_query);
while ($row2 = mysql_fetch_assoc($category_process)) {
$usernames[] = $row2['username'];
}
}
This takes the set category from the URL and queries the database for usernames that match this and puts it into an array.
Now, what I need to do is use additional "filters" to narrow down those usernames. My issue is: if the $usernames array is already set, how can I create a looped query that will check out each username and then return a subset array that matches?
For example, let's say $usernames is already set by the previous bit of code because we already have a $_GET['cat'] variable set. Now we add another $_GET variable "rev":
if (!empty($_GET['rev']) && isset($usernames)) {
//Need to create loop here that will take all usernames in array from the previous block of code, check them for rev matching specific number, and return those that match into the $usernames array.
}