| | |
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
•
•
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>';
Happy Humbugging Christmas
•
•
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 |
Tag cloud for dropdownlist, explodefunction, php
access ajax amf api array asp beginner class close cms code codes combo countryselector curl data database date dehasher display downloader dropdownlist email execution explodefunction file files flash form forms function head html image include insert integration java javascript jquery js lamp limit link linux listbox login loop mail malfunctioning menu mimic module multiple multipletables mysql net netbeans object oop outofmemmory paypal php post printer query reuse rss script search searchmonkey security send server session simple smash sms soap sorting spam sql structure table traffic trouble tutorial up-to-date upload user validation variable vbulletin video virus web webdesign xml youtube zend







