Welcome Guest, Not a member yet? Register   Sign In
populate a form using set_select
#1

[eluser]JuanitoDelCielo[/eluser]
Hi there guys. I was working in a CRUD but I have problems with the set_select function

I get the information from the database and I tried to use this code to set the value from the database to the select among the other options.

This is my code where $user->city it's the value from the database and it's a numeric value.

Code:
$user->city = 1;

<select name="city">
   <option value="0" &lt;?php set_select('city', $user->city)?&gt;>A</option>
   <option value="1" &lt;?php set_select('city', $user->city)?&gt;>B</option>
   <option value="2" &lt;?php set_select('city', $user->city)?&gt;>C</option>
</select>

Acording to my logic if $user->city its equal to 1 the secound option shoul get the selected atribute but it doesn't what I'm doing wrong?




Theme © iAndrew 2016 - Forum software by © MyBB