Re: Making a Loop.[Scanned]

From: Date: Wed, 12 Mar 2003 09:03:45 +0000
Subject: Re: Making a Loop.[Scanned]
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-139245@lists.php.net to get a copy of this message
echo"<select name=\"$number\" size=\"1\">"; // in this statement you are asking that a number be a variable in php and that is not permitted. try: for ($i=0;$i<=10;$i++) { echo "<select name=\"var_name[$i]\" >"; // this way your select name is "var_name[1]" and not 1 also, echo "<option value=\"$productCode\">$productCode</option><br>"; try instead, echo "<option>$productCode; // no <br> needed here and the <option> doesn't need a value ----- Original Message ----- From: "Philip J. Newman" <newmanpj@philipnz.com> To: "Michael Egan" <MEgan@3tc.org.uk>; <php-general@lists.php.net> Sent: Wednesday, March 12, 2003 12:32 AM Subject: Re: [PHP] Making a Loop.[Scanned] > assuming the value is 10, I stall can't get it to work > > > ----- Original Message ----- > From: "Michael Egan" <MEgan@3tc.org.uk> > To: "Philip J. Newman" <newmanpj@philipnz.com>; <php-general@lists.php.net> > Sent: Wednesday, March 12, 2003 9:29 PM > Subject: RE: [PHP] Making a Loop.[Scanned] > > > Philip, > > I might be missing something but just looking at the top few lines of your > code the $number variable has no value. > > The loop will run on howver many times corresponds to this value - with the > value being null it's not going to run. > > You'll need to pass in a value from elsewhere. > > Michael Egan > > -----Original Message----- > From: Philip J. Newman [mailto:newmanpj@philipnz.com] > Sent: 12 March 2003 08:21 > To: php-general@lists.php.net > Subject: [PHP] Making a Loop.[Scanned] > > > I have this code to make this form list $x amount of times. > > for ($i = 1; $i <= $number; $i++) { > > echo"<select name=\"$number\" size=\"1\">"; > > // LIST ALL PRODUCTS IN DATABASE. > > $sql = "SELECT * FROM products ORDER BY productCode ASC"; > $sql_result = mysql_query($sql, $connection) or die ("Could not > get Query"); > > while ($row = mysql_fetch_array($sql_result)) { > > $productCode=$row["productCode"]; > echo "<option > value=\"$productCode\">$productCode</option><br>"; > > } // END WHILE. > > echo"</select>"; > > > } > > and it dose not work any help? > > ------ > Philip J. Newman. > Head Developer > info@philipnz.com > > +64 (9) 576 9491 > +64 021-048-3999 > > ------ > Friends are like stars > You can't allways see them, > but they are always there. > > ------ > Websites: > > PhilipNZ.com - Design. > http://www.philipnz.com/ > info@philipnz.com > > Philip's Domain // Internet Project. > http://www.philipsdomain.com/ > newmanpj@philipnz.com > > Vital Kiwi / NEWMAN.NET.NZ. > http://www.newman.net.nz/ > philip@newman.net.nz > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#139245) next »