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

hay que quitar un $value....error mio

el otro error esta aca

$fila[$opt]) sobra el parentesis

osea deberia quedar asi parece

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