Jump to content

Capturing Drop Down List Values


kcwebz

Recommended Posts

I have created this form.

 

I am trying to capture the values of the drop down lists but am having a hard time trying to do so, and was hoping someone here might be able to help me.

 

They are being declared using a unique identifier of their respective tables from my sql db. each section of product in that form has its own table and own table id which the drop down lists are using. They are declared in the form like this.

 

 

 

echo "<td><select name=". $row['goosedown_id'] .">
               <option value=''> 0 </option>
               <option>1</option>
               <option>2</option>
               <option>3</option>
               <option>4</option>
               <option>5</option>
               <option>6</option>
               <option>7</option>
               <option>8</option>
           </select>
       </td>";

 

Once the user hits submit I then try to capture these drop down lists in my orderform.php like so (this is also where I am having trouble)

 

 

$goosedown_id = ($_POST[$row['goosedown_id']]);
//..


/*-------------------First Email--------------------*/

/* Set Email for Redgraves, so they can for-full the order form */
$message = "Your contact form has been submitted by:

Order number : $random

Name: $yourname
E-mail: $email
Phone Number: $phonenumber
Mobile Number: $mobilenumber
Delivery Address : $deliveryaddress

Order:
-----------------------------------------------------------------

test goosedown_id: $goosedown_id

"foreach  ($_POST[$row['goosedown_id']] != 0) {
  "test goosedown_id: $goosedown_id"
  }"

-----------------------------------------------------------------



Comments:
$comments



End of message
";

/* Send the message using mail() function */
mail($myemail, "Order Submitted", $message);

 

As you can see I have made a minor attempt at getting the drop down lists values that are not equal to 0.. but this code is defiantly not working.. but hopefully it serves a purpose to show you waht I am trying to achieve.. any help would be greatly appreciated.. been stuck on this problem all weekend. :P

Link to comment
Share on other sites

I was just trying to show people what I am trying to achieve, I don't really know how to put it into words.. I have tried so much now just to get one of thedrop down lists values to be printed out that I dunno what else to do.

Link to comment
Share on other sites

It should be as simple as adding the array name in the name atribute of your select fields. Then each key will be the value of $row['goosedown_id']

 

echo "<select name=\"array_name_goes_here[{$row['goosedown_id']}]\">\n";

 

followed by your <option></option> tag sets, etc. Repeat for each select field, then

 

echo '<pre>';
print_r($_POST);
echo '</pre>';

 

to see the structure of the data. You should be easily able to loop over it once you see the structure.

Edited by Pikachu2000
Link to comment
Share on other sites

If you haven't done so already, you might want to read the PHP manual. If you start on the chapter I linked you to, and at least read everything up to the chapter about Classes, it should explain most of the things you'll need with PHP.

The "Function Reference" chapter is also very useful, but that's more of a "when needed" basis. Though, if you want to read through it all, then all the more power to you. :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.