Set multiple values as selected when the page loads in codeigniter


#1

Hola a todos, como marco como selected al cargar la pagina:

echo form_open(base_url().‘modificar_’.$tabla);
foreach ( $campos as $campo => $valor )
{
foreach ($pops as $fila)
$aux[]=$fila->$campo;
$registro=array_unique($aux);
unset($aux);
$cuenta=sizeof($registro) - in_array(’’,$registro);
// Voy imprimiendo el primer select
echo “

”.$cuenta."
“;
echo “$nombres[$campo]”;
foreach( $registro as $valor2 )
{
echo “<option value=’”.$valor2.”’";
if ( $valor2 == $valor && $valor != “” )
echo “selected=‘selected’”;
echo “>”.$valor2."";
}
echo "
Go!

";
echo “”;
}
echo form_close();

in the view:::::

thanks!!!


#2

I find the solution:: using codeignietr framework, but apply in others cases…