Ver Mensaje Individual
  #2 (permalink)  
Antiguo 27/12/2011, 13:55
dannyalfonzo
 
Fecha de Ingreso: febrero-2011
Mensajes: 18
Antigüedad: 13 años, 2 meses
Puntos: 9
Respuesta: es posible este substr

yo siempre lo hago de este modo:

<select id="tablaselect" onchange="algunafuncion(this.value);">
<option value="">Seleccione</option>
<?$db->cargar_select("select campo_a_mostrar, campo_value from table","campo_value","campo_a_mostrar");?>
</select>

y en una clase coloco el metodo para llenarlo

/*Método para cargar un combo <select> html*/
function cargar_select($sql,$varvalue,$varmostar){

$this->sql = $sql;
$this->varmostar = $varmostar;
$this->varvalue = $varvalue;

$this->stmt = $this->ejecutar($this->conexion,$this->sql);

while ($row = $this->obtener_fila($this->stmt)){

echo "<option value='".$row[$this->varvalue]."' >".$row[$this->varmostar]."</option>";

}
}

si no quieres trabajar con objetos no importa, en la funcion cargar select lanzas los querys como tu quieras lo importante es que retorne los options