PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I am building a CMS for a real estate site, with COMMERCIAL and RESIDENTIAL page listings. The CMS has ADD/SELECT/EDIT/DELETE pages for both sections. The ADD page is a basic form page, with a coulple of DROP MENUs; when submitted the data is recored in a MYSQL database.
The EDIT page is a mirror of the ADD page; the data is retrieved from the database and placed into the form fields for editing by the user - except for the DROP DOWN MENUs. The drop menus default to the first value in the form but I can't seem to get the DROP MENUs on the EDIT page to show the value that is in the database.
<select name="restype" class="">
<option selected value="">
<option value="SINGLE FAMILY HOME">SINGLE FAMILY HOME
<option value="DUPLEX FAMILY HOME">DUPLEX FAMILY HOME
<option value="MULTI FAMILY PROPERTY">MULTI FAMILY PROPERTY
<option value="CONDOMINIUM">CONDOMINIUM
<option value="LAND (RESIDENTIAL)">LAND (RESIDENTIAL)
</select>
Been working with PHP MYSQL for less than a year, so my apolgy if this is "no brainer".
Ummm, is this not causing some items displayed twice? Not profy.
That solution doesn't make much sense.
yeah, the variable $restype does show up twice in the drop down menu - once as the selected choice and again in the menu as a regular choice. my client is not very computer literate so I am interested in any other solution to the one above.
Your solution is not a solution at all. What you want to do is, as you build the drop down menu, check each item in the menu to see if it is the same as what is know from the database. If it is, echo ' selected="selected"', otherwise echo nothing.