| | |
Getting Explode Array into cart
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Sep 2009
Posts: 6
Reputation:
Solved Threads: 0
Hi , I am using an explode function to split some comma separated colors into a drop down list.
The drop down works perfectly but I can't seem to get that info into the cart. If I use a standard drop down list in dreamweaver, no problem binding that to the cart. Just not sure how to bind the selection from a php generated list into the cart?
any help would surely be appreciated.
thanks nigel
PHP Syntax (Toggle Plain Text)
<?php // Split the string up into an array of values $dropdown_data = explode(",", $row_rsApparel['Item_Colors']); // Output a dropdown echo '<select name="color" id = "color">'; foreach($dropdown_data as $key => $value) { echo '<option value="'.$key.'">'.$value.'</option>'; } echo '</select>'; ?>
The drop down works perfectly but I can't seem to get that info into the cart. If I use a standard drop down list in dreamweaver, no problem binding that to the cart. Just not sure how to bind the selection from a php generated list into the cart?
any help would surely be appreciated.
thanks nigel
You use the $_POST array variable in your form handling routine to get the select value, namely $_POST['color'] in your case. Once you get this, simply use it in your update/insert SQL query.
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Sep 2009
Posts: 6
Reputation:
Solved Threads: 0
Thanks so much ardav, I'm close, I am getting info into the cart from that drop down, but it is putting the number of the array into the cart instead of the color name (red,blue,etc.)
I'ver tried this but no luck:
I'm not sure how to get the actual color value in syntax wise. Kind of new to php.
I'ver tried this but no luck:
PHP Syntax (Toggle Plain Text)
"".((isset($_POST["Color2.$value"]))?$_POST["Color2.value"]:"") ."";
I'm not sure how to get the actual color value in syntax wise. Kind of new to php.
This is because your the $_POST['color'] is picking up the array 'key' value and not the value displayed in the dropdown. Do this:
I think that should work.
PHP Syntax (Toggle Plain Text)
echo '<select name="color" id = "color">'; foreach($dropdown_data as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } echo '</select>';
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
•
•
Join Date: Sep 2009
Posts: 6
Reputation:
Solved Threads: 0
•
•
•
•
This is because your the $_POST['color'] is picking up the array 'key' value and not the value displayed in the dropdown. Do this:
I think that should work.PHP Syntax (Toggle Plain Text)
echo '<select name="color" id = "color">'; foreach($dropdown_data as $value) { echo '<option value="'.$value.'">'.$value.'</option>'; } echo '</select>';
![]() |
Similar Threads
- [b]How the break data in Array..?? [/b] (PHP)
- Validate Input Fields (PHP)
- 5 star rating system messes up my numbers (PHP)
- Php session array help please (PHP)
- checkbox storing to mysql (PHP)
- PEAR email (PHP)
- Deleting a line from a file (PHP)
- my cart problem (PHP)
- Complete List of Mysql Commands for PHP tokenization script. (PHP)
Other Threads in the PHP Forum
- Previous Thread: Error on sending mail for checked values
- Next Thread: pagination with mySql
| Thread Tools | Search this Thread |
access ajax ajaxcode array asp asp.net beginner body broken c# cheap class cms code combo confirm curl data database display dropdownlist dropdownmenu email enter error execute external files flash flex form forms gentoo google hack html image include integration java javascript joomla jquery lamp libcurl limit link links linux local login mail malfunction memmory menu mobile module mssql multiple mysql navigation net oop password paypal pdf php post query remote reuse script search security seo session sms soap sockets spam sql subscription survey tutorial upload validation vbulletin video visualstudio web webbrowser webdesign websphere window xml xslt y!os yahoo youtube zend







