In HTML: <SELECT name="manufacturernames[]" multiple> (note the name has PHP-like array definition)
In PHP: for ($i=0;$i<sizeOf($manufacturernames);$i++) { if ($i==0) { $q_cond="where"; } else { $q_cond="or"; } $query.="$q_cond MANUFACTURER LIKE '$manufacturernames[$i]'"; } Gisele Grenier wrote: > Hi everyone, > > This is a php and mysql question... > > I've spent days trying to figure this out and can only find help on one or > the other.. not both things that I'm trying to do. > > I have a table called inventory which contains the following: > > manufacturer > product > price > > I have a php form that has a list box that contains distinct values from the > inventory table as follows: > $sql = "SELECT DISTINCT MANUFACTURER FROM inventory ORDER BY MANUFACTURER > ASC"; > > // execute SQL query and get result > $sql_result = mysql_query($sql,$connection) > or die("Couldn't execute query."); > > // put data into drop-down list box > while ($row = mysql_fetch_array($sql_result)) { > > $manufacturername = $row["MANUFACTURER"]; > $option_block.= "<OPTION > value=\"$manufacturername\">$manufacturername</OPTION>"; > } > > Then the list box is created: > > Select a manufacturer > <SELECT name="manufacturername"> > <option>All</option> > <? echo "$option_block"; ?> > </SELECT> > > All this works great when selecting only one manufacturer to display. The > data is passed to: $query .= "WHERE MANUFACTURER LIKE '$manufacturername' > > Where I'm having a problem is that I want to be able to select multiple > manufacturers to search. > > I know that I need to add multple to the select as: > <SELECT name="manufacturername" multiple> > > and that's about it...I'm lost after this. > > can anyone shed any light on this? > > Thanks, > > Gisele Grenier > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]