Ver Mensaje Individual
  #2 (permalink)  
Antiguo 15/09/2010, 07:45
Avatar de Perr0
Perr0
 
Fecha de Ingreso: mayo-2005
Ubicación: Santiago de Chile, Chile
Mensajes: 676
Antigüedad: 18 años, 10 meses
Puntos: 79
Respuesta: ayuda con combobox

Código PHP:
Ver original
  1. <?php
  2. //SUPONIENDO QUE $value ES EL VALOR DEL COMBO
  3. //EN LA CONSULTA SE BUSCA LA ETIQUETA
  4. function cargar_combobox($value,$opt,$sql,$value){
  5.     $enlace = mysql_connect('fffffff.com','root','pasw')or die ('Ha fallado la conexi&oacute;n: '.mysql_error());
  6.     mysql_select_db('magic')or die ('Error al seleccionar la Base de Datos: '.mysql_error());
  7.    
  8.     $res = mysql_query($sql) or die (mysql_error());
  9.    
  10.     echo "<select name='combobox_expansion' class='botones'>";
  11.     while($fila = mysql_fetch_assoc($res)){
  12.         unset($value_seleccionado); //RESETEO PARA ANTES Y DESPUES DE ENCONTRAR UNA COINCIDENDCIA
  13.         if($fila[$opt])==$value) $value_seleccionado="selected='selected'";
  14.         echo "<option value='$fila[$value]' $value_seleccionado>$fila[$opt]</option>";
  15.     }
  16.     echo "</select>";
  17.     mysql_close($enlace);
  18. }
  19. ?>

salu2