Skip to content
Advertisement

Why is the first entry of an HTML dropdown not present in a PHP array

I have inserted a portion of code that includes a dropdown that retrieves a list through PHP SELECT etc. When it retrieves the entries (there are about 3000) in the dropdown, it always excludes the first entry. If I then select an entry, the return result in the form is the previous entry, e.g., if I select entry 10 in the dropdown through a SUBMIT button, the returned result is entry 9. I assume it is associated to the first entry not being present.

JavaScript

Advertisement

Answer

Clean up your code and order by id ascending to guarantee getting the right order. also only call fetchAll once initally.

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement