Re: Select list with PHP

From: Date: Mon, 05 Feb 2001 20:20:32 +0000
Subject: Re: Select list with PHP
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-38333@lists.php.net to get a copy of this message
You need to reset: $option = ''; before each product. So, inside the while(...mysql_fetch_row()) loop, but outside the while(...$colors) loop. -- Visit the Zend Store at http://www.zend.com/store/ Wanna help me out? Like Music? Buy a CD: http://l-i-e.com/artists.htm Volunteer a little time: http://chatmusic.com/volunteer.htm ----- Original Message ----- From: Gerry <gerry@spiralwire.com> To: Richard Lynch <richard@zend.com> Cc: <php-general@lists.php.net> Sent: Sunday, February 04, 2001 10:23 AM Subject: Re: [PHP] Select list with PHP > This worked! > But, I get this color selection increment on each subsequent menu where > the colors from the row above mix with the ones below and so on. Assume > that the numbers are the actual colors: > > Select a color: > ---------------------------- > first menu1 next menu-> 1 next menu-> even longer > 2 2 > 3 3 > 4 4 > 5 5 > 1 > 2 > 3 > 4 > 5 > > mysql_connect(); > while ($row = mysql_fetch_array($sql_result)) { > echo"<tr><td>"; > echo $row["paint"]; > echo"</td><td>"; > echo $row["bucket"]; > echo"</td><td>"; > echo"<form action=\"http://www.\" > method=\"POST\">"; > $Colors = $row["Color"]; > $options = explode(",", $Colors); > while (list(,$Color) = each($options)){ > $option .= "<OPTION>$Color</OPTION>\n"; > } > echo"<select name=\"Colors\">"; > echo "$option"; > echo"</select>"; > echo"</td></tr>"; > echo"</form> > > > It's usually a better idea to store this as a "relation": > > I'm afraid so. > > Thanks: > Gerry Figueroa > > ----------------- > Modern Confucious: > Man who run behind car get exhausted. >

« previous php.general (#38333) next »