Jump to content

Value of a Post from a Select Menu


kreut

Recommended Posts

Hello,

 

I'm using a dynamically created select menu for a user to make a choice which will then be put in my database with the following code:

<select>
      <?php foreach ($course_number as $row) {
    echo "<option value = '{$row['course_id']}'";
    if ($errors && $_POST["course_id"] == $row['course_id']) {echo 'selected = "selected"';
    }
    echo ">{$row['course_number']}</option>";
    } ?>

Unfortunately, I'm having some problems figuring out how to pull off the selected value.  Right now my database portion looks like this:

$data = array('assignment_name' => $_POST['assignment_name'],
				  'due_date' => $_POST['due_date'],
				  'course_id' =>  $_POST["row['course_id']"]);

	$inserted = $dbWrite->insert('assignments_instructors',$data)

 

While the assignment_name and due_dates work (they come from text fields), my course_id gives me an Undefined index: row['course_id'] error.  Any help would be appreciated.

 

Thank 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.