On Mon, 26 Mar 2001 15:50, Peter Houchin wrote:
> Hiya,
> 
> I'm creating a page where the user can select multiple  options to
> query the DB with i am at the moment i can't get more than 1 record to 
> display from the db at all. If any one could offer soem suggestions i
> would be very grateful 
 
> 
> 
> <?
> //db connect info above
> if ($Submit) {
>       $rs = "SELECT * FROM machine WHERE avail='y' AND system='$system'";
>       $result = mysql_query($rs);
>       $system = mysql_result($result, 0, 'system');
>     $serial = mysql_result($result, 0, 'serial');
>     $availe = mysql_result($result, 0, 'avail');
>                       echo "$system $serial $avail";
>       }       
> echo mysql_error();                   
> 
> ?>
> <form name="machine" method="get" action="<? echo $PHP_SELF;?> ">
>   <table width="463" border="1">
>     <tr> 
>       <td width="21%">MODEL</td>
>       <td colspan="2">Config</td>
>       <td width="14%"> Available </td>
>       <td width="12%">Weekly</td>
>       <td width="14%">Monthly</td>
>     </tr>
>     <tr> 
>       <td width="21%"> 
>         <select name="system" size="3" multiple>
>           <option value="sparc 5">Sparc 5</option>
>           <option value="sparc 20">Sparc 20</option>
>           <option value="ultra_1">Ultra 1</option>
>           <option value="ultra 2">Ultra 2</option>
>           <option value="ultra 5">Ultra 5</option>
>           <option value="ultra 10">Ultra 10</option>
>         </select>
>         <input type="submit" name="Submit" value="Submit">
> 
>       </td>
>   </tr>
> </table>  <br>
>   <br>
> </form>

You have several problems here; first is that the name of your 'select 
multiple' box should be system[] in order to  be able to pass ALL the 
selected items - otherwise you only get the last one selected.

That will then give you an array named system, which you'll need to parse 
and break up into a query like

WHERE ... system = '$system[0]' OR system = '$system[1] ... OR system = 
'$system[n]'

Lastly, you seem to have omitted the loop to cycle through all the rows 
of your result set ;-(

-- 
David Robley                        | WEBMASTER & Mail List Admin
RESEARCH CENTRE FOR INJURY STUDIES  | http://www.nisu.flinders.edu.au/
AusEinet                            | http://auseinet.flinders.edu.au/
            Flinders University, ADELAIDE, SOUTH AUSTRALIA

-- 
PHP General 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