Re: [PHP] PHP and listbox multiple selections
Notice the "[ ]" at the end of the select box name, this prompts php to treat the values as an array. $myrow[1]"; } } ?> When the form is submitted I fire this code $mycount = count($options); // get the number of elements in the array (selected in the drop down) while($mycount){// cycle through the array decrementling your counter var ($mycount) untill you have inserted all of the values. $mycount--; mysql_query("INSERT INTO table (value1,value2) VALUES ($value1,$options[$mycount])"); } I hope this helps, it works perfectly for me and uses less code than other examples I have seen. > On Monday, January 28, 2002, at 10:41 AM, Simos Varelakis wrote: > >> A php form contains a listbox (named foolist) with n Items which >> can be >> multiple selected and form posted to >> results.php how can results.php determine which items were selected >> in order >> to add all the items in a Mysql table ??? > -- 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]
Re: [PHP] PHP and listbox multiple selections
On Monday, January 28, 2002, at 10:41 AM, Simos Varelakis wrote: > A php form contains a listbox (named foolist) with n Items which can > be > multiple selected and form posted to > results.php how can results.php determine which items were selected in > order > to add all the items in a Mysql table ??? You can define each in a listbox with an array element as its value. Like so: Item 1 Item 2 Item 3 That's one way to do it. Personally, if I'm populating a listbox with results returned from a SQL query, I use the primary key of the record as the "value" attribute in . Erik Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- 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]
Re: [PHP] PHP and listbox multiple selections
> Hello to everyone > > Problem : > > A php form contains a listbox (named foolist) with n Items which can be > multiple selected and form posted to > results.php how can results.php determine which items were selected in order > to add all the items in a Mysql table ??? > > thanks in advance for any suggestion > and excuse my bad english knowledge :-)) > Pretty english ;) Rename it to foolist[] and when posted look at array $foolist. Valentin Petruchek (aki Zliy Pes) *** Cut the beginning *** http://zliypes.com.ua mailto:[EMAIL PROTECTED] -- 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]
[PHP] PHP and listbox multiple selections
Hello to everyone Problem : A php form contains a listbox (named foolist) with n Items which can be multiple selected and form posted to results.php how can results.php determine which items were selected in order to add all the items in a Mysql table ??? thanks in advance for any suggestion and excuse my bad english knowledge :-)) kind rgds to all simos -- 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]