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
https://forums.phpfreaks.com/topic/227750-value-of-a-post-from-a-select-menu/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.