Welcome Guest, Not a member yet? Register   Sign In
set select to repulate lists from forms
#1

[eluser]alvaroeesti[/eluser]
The guide says that to repopulate a select list from a form after having to return to it

you do this


Code:
<option value="one" &lt;?php echo set_select('myselect', 'one', TRUE); ?&gt; >One</option>

However, that is when you hard code it, which is the least of the cases. How do you go about when you are populating your lists dynamically from a db? such as in this:

Code:
&lt;?php foreach($paises as $pais): ?&gt;
  <option value ="&lt;?php echo $pais->id_pais?&gt;">&lt;?php echo $pais->nombre_pais?&gt;</option>
  &lt;?php endforeach;?&gt;

I have this, but it aint working

Code:
<select name ="paises" id = "paises">
  &lt;?php foreach($paises as $pais): ?&gt;
  <option value ="&lt;?php echo $pais->id_pais?&gt;">&lt;?php echo set_select('paises', $pais->id_pais);?&gt;&lt;?php echo $pais->nombre_pais?&gt;&lt;?php echo set_select('paises', $pais->nombre_pais);?&gt;</option>
  &lt;?php endforeach;?&gt;


Messages In This Thread
set select to repulate lists from forms - by El Forum - 10-13-2012, 09:55 AM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:11 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:19 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:29 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:35 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:37 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:51 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:53 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 01:57 PM
set select to repulate lists from forms - by El Forum - 10-13-2012, 02:01 PM



Theme © iAndrew 2016 - Forum software by © MyBB