We help IT Professionals succeed at work.
Get Started

Two values from one drop-down list

Eurodolphin asked
Last Modified: 2013-12-12
My website deals with the planning of training courses.  One database table, "courses", has a text field 'course' for course names and a corresponding index integer field 'course_id'.
Another table 'planning' also has the 'course_id' field.
On a PHP page that adds a training plan, the user selects a training course from a drop-down list. The corresponding 'course_id' value is passed to the INSERT statement and inserted into the 'course_id' field in the planning table.
So far so good. However, I also want to insert the value of 'course', a text string, into another table using a second INSERT statement.
My question is: how do I pass the value of 'course' to the second INSERT statement?

The Dreamweaver-generated code which creates the drop-down list is as follows:

<select name="course_id" id="course_id">
do {  
<option value="<?php echo $row_RecordsetGetCourses['']?>"><?php echo $row_RecordsetGetCourses['course']?></option>
} while ($row_RecordsetGetCourses = mysql_fetch_assoc($RecordsetGetCourses));
  $rows = mysql_num_rows($RecordsetGetCourses);
  if($rows > 0) {
      mysql_data_seek($RecordsetGetCourses, 0);
        $row_RecordsetGetCourses = mysql_fetch_assoc($RecordsetGetCourses);

'$RecordsetGetCourses' is a simple MySQL query: "SELECT * FROM courses ORDER BY course ASC"
Watch Question
Don't talk to me.
This problem has been solved!
Unlock 2 Answers and 15 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE