I've done stuff like this in VBScript and haven't yet done it in PHP,
so this advice may be worth what you're paying for it:

1. Make sure you've got a space in your sql string.
        $query .= "WHERE MANUFACTURER LIKE '$manufacturername'
should be
        $query .= "  WHERE MANUFACTURER LIKE '$manufacturername'
(note the space before the "WHERE"). Otherwise your sql will be
        DISTINCT MANUFACTURER FROM inventoryWHERE manufacturer
        LIKE 'GE' ORDER BY Manufacturer ASC

2. When your form is submitted, the value of $manufacturername will be
a comma-delimited list of all the values they selected. If your query
will be based on this selection, then it must read:
        SELECT ... WHERE Manufacturer IN ('$manufacturername')

3. You can use 'size="n"' to control the heigth of the form object
        <SELECT name="manufacturername" multiple size="2">

-The only domestic animal not mentioned in the Bible is the cat.

> -----Original Message-----
> From: Gisele Grenier [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 01, 2002 9:53 PM
> Subject: Multiple select list box to search mysql database
> 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:
> 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"; ?>
> 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]

Reply via email to