| | |
posting a multiple select form object
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
I have a form that I am trying to post to a table, everything works fine except for the one multiple select option I have. When it posts to the table, only the last selected option shows. How do I get it to either a. post to separate fields in the table or b. post to the same field separated by a delimiter??
•
•
Join Date: Apr 2009
Posts: 3
Reputation:
Solved Threads: 0
This is the code for the form input:
Since there is an option to select multiple answers, I would like for all of the answers to be recorded in the database however, the only answer it posts it the last of the group. for example say 6th, 7th, and 8th were all selected. When the form is submitted, only "8th" gets posted to the correct field. Does that make sense?
PHP Syntax (Toggle Plain Text)
<select name="grades" size="5" multiple id="grades"> <option value="Pre K">Pre K</option> <option value="Kindergarten">Kindergarten</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3th">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> <option value="6th">6th</option> <option value="7th">7th</option> <option value="8th">8th</option> <option value="9th">9th</option> <option value="10th">10th</option> <option value="11th">11th</option> <option value="12th">12th</option> </select>
•
•
•
•
This is the code for the form input:
Since there is an option to select multiple answers, I would like for all of the answers to be recorded in the database however, the only answer it posts it the last of the group. for example say 6th, 7th, and 8th were all selected. When the form is submitted, only "8th" gets posted to the correct field. Does that make sense?PHP Syntax (Toggle Plain Text)
<select name="grades" size="5" multiple id="grades"> <option value="Pre K">Pre K</option> <option value="Kindergarten">Kindergarten</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3th">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> <option value="6th">6th</option> <option value="7th">7th</option> <option value="8th">8th</option> <option value="9th">9th</option> <option value="10th">10th</option> <option value="11th">11th</option> <option value="12th">12th</option> </select>
html Syntax (Toggle Plain Text)
<select name="grades[]" size="5" multiple id="grades">
foreach($_POST['grades'] as $value) to get each of the selected value. Last edited by peter_budo; Apr 18th, 2009 at 4:51 am. Reason: Correcting closing tag
Ignorance is definitely not bliss!
*PM asking for help will be ignored*
*PM asking for help will be ignored*
Hi,
Use the following code.
Use the following code.
PHP Syntax (Toggle Plain Text)
<? $selectedGrades=$_POST['grades']; foreach ($selectedGrades as $item) echo $item."<br>\n"; ?> <form name=frm action="" method="post"> <select name="grades[]" size="5" multiple id="grades[]"> <option value="Pre K">Pre K</option> <option value="Kindergarten">Kindergarten</option> <option value="1st">1st</option> <option value="2nd">2nd</option> <option value="3th">3rd</option> <option value="4th">4th</option> <option value="5th">5th</option> <option value="6th">6th</option> <option value="7th">7th</option> <option value="8th">8th</option> <option value="9th">9th</option> <option value="10th">10th</option> <option value="11th">11th</option> <option value="12th">12th</option> </select> <input type=submit value=submit> </form>
Vivek Rawat
Keep solving complexities.
Keep solving complexities.
use foreach($_POST['grades'] as $value) to get each of the selected value.
WWW.GAMEGAPE.COM
More games, more gapes
GameGape is the premier social gaming network where people can chat, make friends, write blogs, play games and save their high scores. With a showcase of hundreds of free online games, GameGape is regarded for its high-quality games suitable for the entire family.
More games, more gapes
GameGape is the premier social gaming network where people can chat, make friends, write blogs, play games and save their high scores. With a showcase of hundreds of free online games, GameGape is regarded for its high-quality games suitable for the entire family.
![]() |
Similar Threads
- Help with automatic update problem and more (Viruses, Spyware and other Nasties)
- Insert to DB & View Results on Different Page (ASP.NET)
Other Threads in the PHP Forum
- Previous Thread: Parse error: syntax error, unexpected $end
- Next Thread: Write to a HTML page using PHP?
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date development directory display download dynamic echo email error file files filter folder form forms function functions gc_maxlifetime google host href htaccess html image include insert integration ip java javascript joomla limit link login loop mail memmory memory menu mlm mod_rewrite multiple mysql navigation oop parse parsing paypal pdf php problem query radio random recursion regex remote script search server sessions sms snippet soap source space sql structure syntax system table thesishelp tutorial update upload url validation validator variable video web xml youtube






