Welcome Guest, Not a member yet? Register   Sign In
Proper way to populate dropdown?
#1

[eluser]Vasi[/eluser]
Hi Guys,

I want to populate a drop-down list with categories and subcategories from my database table.

Which would be the best / proper way to populate it?

Any tip would be great, thanks.
#2

[eluser]evolutionxbox[/eluser]
I don't think there is a 'proper' way to populate the drop down.

Use a model to get the info from the database, use your controller to pass the info to the view and use the view to output the info.

Use a foreach loop to help output the drop down, also formating your drop down like so:
Code:
<select>
  <optgroup label="Swedish Cars">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
  </optgroup>
  <optgroup label="German Cars">
    <option value="mercedes">Mercedes</option>
    <option value="audi">Audi</option>
  </optgroup>
</select>
will make life a bit easier for you and your users (in my opinion).




Theme © iAndrew 2016 - Forum software by © MyBB