0

I have a form with an option menu with Staff_Names that gets its data from "Staff" table:

<select class="form-control" name="Name" id="Name">

    <option value="">select staff</option>
    <?php do { ?>
        <option value="<?php echo $row_Staff['Staff_Name'] ?>">
            <?php echo $row_Staff['Staff_Name']?></option>
    <?php } while ($row_Staff = mysql_fetch_assoc($Staff));
    $rows = mysql_num_rows($Staff);
    if($rows > 0) {
        mysql_data_seek($Categories, 0);
        $row_Staff = mysql_fetch_assoc($Staff);
    }
    ?>
</select>

The "Staff" table also has the staff member's Email. The form elements are inserted into a new table called "Training". I would like to select the Staff_Name from the option menu and insert the Staff_Name and Email in separate fields in the Training table. I have tried explode("-", $_POST['Name'] method from How to post two values in an option field? but feel there has to be a more efficient way. I don't want to continue to explode every time I need to echo in subsequent pages. Also, explode only works in this method by exploding on another page. Would like to store both fields from form when inserting into Training table. Does anyone have an efficient method?

Community
  • 1
  • 1
user3258571
  • 386
  • 3
  • 17
  • 1
    you might be best posting the staff id then looking up the details again to insert – makie Jul 20 '16 at 20:39
  • I was hoping there was a JavaScript or json method to echo the email field. Thanks for the suggestion. – user3258571 Jul 20 '16 at 20:42
  • are you trying to save the data on selection? you would need to use ajax to do that if so. I just assumed this was part of a form you were posting to another page. – makie Jul 20 '16 at 20:45
  • Posting both fields to a table. Not familiar with Ajax method. Can you show me? – user3258571 Jul 20 '16 at 20:46
  • Ajax is javascript method for sending data to php without redirecting to another page. – makie Jul 20 '16 at 20:54
  • Need more step by step assistance or javascript please. – user3258571 Jul 20 '16 at 20:57
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/117850/discussion-between-makie-and-user3258571). – makie Jul 20 '16 at 20:58

0 Answers0