Re: multiple record out put

From: Date: Mon, 26 Mar 2001 06:48:36 +0000
Subject: Re: multiple record out put
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-45582@lists.php.net to get a copy of this message
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

« previous php.general (#45582) next »