Darkness Soul Posted April 17, 2006 Share Posted April 17, 2006 Hi guys,So, new ask to you.. really need a newbie help.. ^^"!When I print a multiple option select, and my form is sent, the $_POST just read the last one selected.. not the last click, the last down select.. a sample code like mine that's don't work too..:[code]<?php if ( $_POST['component_select'] != '' ) { print $_POST['component_select'] ; }?><FORM action="teste.php" method="post"><P><SELECT multiple size="10" name="component_select" STYLE="width: 500px;"> <OPTGROUP label="Group 1"> <OPTION value="Component_1_a">Component_1_1</OPTION> <OPTION value="Component_1_b">Component_1_2</OPTION> <OPTION value="Component_1_c">Component_1_3</OPTION> </OPTGROUP> <OPTGROUP label="Group 2"> <OPTION value="Component_2_a">Component_2_1</OPTION> <OPTION value="Component_2_b">Component_2_2</OPTION> <OPTION value="Component_2_c">Component_2_3</OPTION> </OPTGROUP> <OPTION value="Component_3_a">Component_3</OPTION></SELECT><BR><INPUT type="submit" value="Send"><INPUT type="reset"></P></FORM>[/code]If I select all elements, its will print [b]Component_3_a[/b]...Thank you for any help.. =)D.Soul Quote Link to comment Share on other sites More sharing options...
Darkness Soul Posted April 17, 2006 Author Share Posted April 17, 2006 I've done it!!! =DDDDDDDAt PHP, the select need to write many data, but, php will read the last one... how to solute:use [b][][/b] after the name.. why? because php will ready it like an array ;)How we read and print an array guys?? Use [b]for [/b]or [b]foreach[/b].. =DThe code thats work well:[code]<?phpif ( $_POST['component_select'] != '' ){ for ( $i = 0; $i < count ( $_POST['component_select'] ); $i ++ ) { print $_POST['component_select'][$i] .'<br>'; }}?><FORM action="teste.php" method="post"><P><SELECT multiple size="10" name="component_select[]" STYLE="width: 500px;"> <OPTGROUP label="Group 1"> <OPTION value="Component_1_a">Component_1_1</OPTION> <OPTION value="Component_1_b">Component_1_2</OPTION> <OPTION value="Component_1_c">Component_1_3</OPTION> </OPTGROUP> <OPTGROUP label="Group 2"> <OPTION value="Component_2_a">Component_2_1</OPTION> <OPTION value="Component_2_b">Component_2_2</OPTION> <OPTION value="Component_2_c">Component_2_3</OPTION> </OPTGROUP> <OPTION value="Component_3_a">Component_3</OPTION></SELECT><BR><INPUT type="submit" value="Send"><INPUT type="reset"></P></FORM>[/code]Enjoy, D.Soul Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.