oriecat
12-14-2006, 08:38 PM
I have a webpage I have made, to filter a list of emails. Currently it is set up to select by Branch and/or Group, and Branch and Group are drop downs where you can pick one. I would like to change it so that you can pick multiple ones, so I switched the page over so that it is a multiple select, but when it actually runs the query, it only outputs based on one of them.
So the url result shows: "choice=request&search=03&search=04&search2=Q" and the list is only showing the search=04 people, it is ignoring the first search= part.
I am not at all sure how to go about fixing this, or if I am even going about this the right way. I would appreciate any pointers. Thank you.
Here is some of the relevant code:
<FORM METHOD="get" ACTION="emails2.php">
<INPUT TYPE=hidden NAME=choice VALUE="request">
<form name="form1" method="get" action="emails2.php">
Select a Branch:
<select multiple name="search" size=16>
<option value="">All Branches</option>
<option value="03">03 - Portland</option>
...list of options...
</select>
</td>
<td>
Select a Mail Group:
<select multiple name="search2" size=21>
<option value="">All Groups</option>
<option value="A">A - Corporate Administration</option>
...list of options...
</select>
</td></tr>
</table>
<INPUT TYPE="submit" VALUE="Search!" class="btn">
</FORM>
if ($choice == "request")
{
echo "All Selected Emails";
$result =
mysql_query("SELECT * FROM emails
WHERE (Branch LIKE \"%$search%\" OR Branch = 'ALL')
AND (Mailgroup LIKE \"%$search2%\")
ORDER BY Name");
};
So the url result shows: "choice=request&search=03&search=04&search2=Q" and the list is only showing the search=04 people, it is ignoring the first search= part.
I am not at all sure how to go about fixing this, or if I am even going about this the right way. I would appreciate any pointers. Thank you.
Here is some of the relevant code:
<FORM METHOD="get" ACTION="emails2.php">
<INPUT TYPE=hidden NAME=choice VALUE="request">
<form name="form1" method="get" action="emails2.php">
Select a Branch:
<select multiple name="search" size=16>
<option value="">All Branches</option>
<option value="03">03 - Portland</option>
...list of options...
</select>
</td>
<td>
Select a Mail Group:
<select multiple name="search2" size=21>
<option value="">All Groups</option>
<option value="A">A - Corporate Administration</option>
...list of options...
</select>
</td></tr>
</table>
<INPUT TYPE="submit" VALUE="Search!" class="btn">
</FORM>
if ($choice == "request")
{
echo "All Selected Emails";
$result =
mysql_query("SELECT * FROM emails
WHERE (Branch LIKE \"%$search%\" OR Branch = 'ALL')
AND (Mailgroup LIKE \"%$search2%\")
ORDER BY Name");
};