Select option as per base date

Asked

Viewed 24 times

0

I currently have a selection field where there are several options and only one that the user chose, only I wanted to search the one that he automatically chose by the database. I use the code:

<option <?php if ($company == 1 ) echo 'selected' ; ?>value="1">Apple</option>

Just that I have to put all the options. So I would like you to automatically select the option chosen without needing by all with selected, it is possible?

  • It’s not very clear, but if $company value 1, means the user selected Apple, correct? And you want to do something similar with the other options without having to write this PHP code?

  • Yes, I wanted to do from select * from, selecting the options, only here comes the fucked part, besides showing the options wanted q was shown which one is selected, understood?

  • It is not yet very clear. Are these options saved in the database? If yes, have how to put the code you do the select and displays in HTML?

  • let’s wait for more user info

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.