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" <[EMAIL PROTECTED]> To: "Michael Egan" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]> > To: "Philip J. Newman" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > 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:[EMAIL PROTECTED] > Sent: 12 March 2003 08:21 > To: [EMAIL PROTECTED] > 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 > [EMAIL PROTECTED] > > +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/ > [EMAIL PROTECTED] > > Philip's Domain // Internet Project. > http://www.philipsdomain.com/ > [EMAIL PROTECTED] > > Vital Kiwi / NEWMAN.NET.NZ. > http://www.newman.net.nz/ > [EMAIL PROTECTED] > > > > -- > 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php