```I have a drop-down in html which is being rendered from php template. I can edit drop-down choice which takes usernames from DB, but how make it “selected” (what I have choose before) before editing?
<?php
$conn = new mysqli($servername, $username, $password, $dbname) or die ('Cannot connect to db');
The sometimes tricky part is figuring out where to put the variable declaration and assignment if conditional. Give it a try and post back on how you do.
thank you for your reply, but this still not working properly.
I don’t understand why but this one always selected last option ( not the one i choose before). the same is with code :
Much of that doesn’t pertain to what I had in mind.
The “some_variable” and “some_value” that assigns a value to “select_attribute” would not be inside the procNewEntry function unless you wanted to pass the “select_attribute” variable to where it’s needed in some way. IMHO, doing so would make things uneccessarily more complex than needs be. Much easier to have the conditional inside the while loop that generates the select options.
Also, “some_variable” and “some_value” are my way of indicating that “something goes there” and are not meant to be used in the actual code. Sorry if this confused you, I have a habit of assuming others will understand my eccentricities.
So what should those be? It depends on what criteria you want to use to determine which select option, if any, you want to be as the “selected”. I do not know this, it could be the first, the last, one that has a specific id or name etc.
Which select option do you want to be the default selected option?
there is no default option, option depend for which user I add a task.
After I add task for him I want to edit it. And editing is working but option of workers is not selected.