a snippet of my form looks like this:
Expand|Select|Wrap|Line Numbers
- <html>
- <body>
- <form action="...php" method=POST...
- <tr>
- <th scope="col">Beer:</th>
- <th scope="col"><input type="text" name="BeerandWine[Beer][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Beer][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Beer][]" /></th>
- </tr>
- <tr>
- <th scope="col">Wine:</th>
- <th scope="col"><input type="text" name="BeerandWine[Wine][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Wine][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Wine][]" /></th>
- </tr>
- <tr>
- <th scope="col">Liquor:</th>
- <th scope="col"><input type="text" name="BeerandWine[Liquor][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Liquor][]" /></th>
- <th scope="col"><input type="text" name="BeerandWine[Liquor][]" /></th>
- </tr>
- ...</form>
- </body>
- </html>
here is my php code to send it to my email:
Expand|Select|Wrap|Line Numbers
- <?php
- foreach($_POST as $key){
- if (is_array($key)){
- $message.="Category: $key\n";
- foreach($key as $row){
- $message.="Item: $row\n";
- foreach($row as $col => $val){
- $val = stripslashes($val);
- $message.="$col: $val\n";
- }
- }
- }
- }
- ?>
Category: Array
Item: Array
0: Stella
1: 6 pack
2: Cold
Item: Array
0: Merlot
1: 750ml
2:
Item: Array
0: Whiskey
1:
2: With cup
I'ts really a very handy script, except i can't seem to gather anything but 'array' from $key and $row.
How can I make the index name of the nested array display in my email, instead of 'array'. Keeping in mind I have a few hundred inputs.
This is how i want it to look:
Category: BeerandWine
Item: Beer
0: Stella
1: 6 pack
2: Cold
Item: Wine
0: Merlot
1: 750ml
2:
Item: Liquor
0: Whiskey
1:
2: With cup
and i also want to have:
Type/Brand:, Quantity:, Notes:
instead of:
0:, 1:, 2:
and not display the empty values, but those I could probably find on my own after I solve this...I've been searching for a solution to this for days. Any help?