MySQL Forums
Forum List  »  PHP

Select drop down list is only displaying first choice results
Posted by: Douglas Moxley
Date: September 05, 2017 05:57AM

Hello friends!

I am having a problem displaying anyone other than the first employee from my table using select. I know I must use a while or loop but nothing has worked. Any advice is greatly appreciated!

Thank you!
Doug


#### JAVASCRIPT ####
<script type='text/javascript'>
$(function(){
$('#employee').change(function() {
selectedOption = $('option:selected', this);
$('input[name=first_name]').val( selectedOption.data('first_name') );
$('input[name=last_name]').val( selectedOption.data('last_name') );
});
});
</script>

#### SELECT EMPLOYEE ####
<select id="employee">
<option value="">Select an Employee to Display</option>

<option value="John"
data-first_name="<?php echo $row['first_name']; ?>"
data-last_name="<?php echo $row['last_name']; ?>"
>John</option>

<option value="Mary"
data-first_name="<?php echo $row['first_name']; ?>"
data-last_name="<?php echo $row['last_name']; ?>"
>Mary</option>

</select>



#### DISPLAY RESULTS ####
echo ($row['player_first_name']);
echo ($row['player_last_name']);

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.