Ver Mensaje Individual
  #1 (permalink)  
Antiguo 21/06/2010, 20:29
oscaralex09
 
Fecha de Ingreso: junio-2010
Mensajes: 1
Antigüedad: 13 años, 10 meses
Puntos: 0
Problema con switch, get y while

Que tal gente de Foros del Web soy nuevo por aca, pero bueno estoy disfrutando de este foro y ayudare en lo que pueda.

Por el momento tengo un problema estoy haciendo un script en php y javascript con onchange la cosa esta asi:


en la pagina html tengo lo siguiente

Código HTML:
<?php require_once('test.php');
      genera_form();
   ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script>
function adjs(url){
    oldsc=document.getElementById("old_sc");
       if(oldsc)
            document.getElementsByTagName('body')[0].removeChild(oldsc);
    sc=document.createElement('script');
    sc.id="old_sc";
    sc.src=url+'&'+Math.random();
    document.getElementsByTagName('body')[0].appendChild(sc);
}
</script>
</head>

<body>
<form >
 <select name="paquete" id="paquete" class="selectInput" onChange="adjs('?p&sel='+this.value)">
<?php 
require_once('bar.php');


                          mysql_select_db($database_bar,$bar);
			              $busqueda = mysql_query("Select distinct nombre_paquete FROM tb_paquetes ");
			              while ($querico = mysql_fetch_array($busqueda)) {	
						  
						
?>

                    <option value="<?php echo $querico['nombre_paquete']; ?>"><?php echo $querico['nombre_paquete']; ?></option>
                   
                   <?php } ?> 
                    
            </select>

					  
           <div id="pp"></div>
           <div id="pp2"></div>
           	</form>	
</body>
</html> 
vemos que desde HEAD tenemos un javascript el cual genera la funcion de que cuando cambiemos algun valor del select devolvera un dato el cual viene desde aca:

Código PHP:
<?php
function genera_form(){
                    
                    if(isset(
$_GET['p'])){
                          
                      switch(
$_GET['sel']){
                      case 
'Escuelas de Iniciacion':
                           
$ret=array('Banamex','Banorte','BBVA','Bancomer','Scotia Bank');
                           
$html2='<br><br><font size=\"-1\">Numero de Referencia&nbsp;</font><input type=\"text\" name=\"no_ref_banco\" id=\"no_ref_banco\"  />';
                           
$html='<br><br><select name=\"banco\" id=\"banco\"  class=\"selectInput\">';
                     
                      break;
                      
                     
       
                      exit;
                   
                    }
                    
                          
           
                    foreach(
$ret as $v)
           
                          
$html.='<option value=\"'.$v.'\">'.$v.'</option>';
           
                          
$html.='</select>';
           
                    echo 
'document.getElementById("pp").innerHTML="'.$html.'";';
                    echo 
'document.getElementById("pp2").innerHTML="'.$html2.'";';
           
                    exit;
           
                    } 
                    
                    

          
          
          }
          
          
?>
EL CODIGO PHP ANTERIOR SI LO PRUEBAN FUNCIONA PERO AL MOMENTO DE REALIZAR UNA CONSULTA A MYSQL CON WHILE COMO EN EL SIGUIENTE EJEMPLO DEJA DE FUNCIONAR USANDO $_GET PERO SI LO REMPLAZO POR ALGUNA VARIABLE FUNCIONA BIEN VERIFIQUEN Y ESPERO PUEDAN AYUDARME GRACIAS¡¡¡
Código PHP:
<?php
   
require_once('bar.php');
   
mysql_select_db($database_bar$bar);
   
$buscando mysql_query("SELECT DISTINCT duracion_paquete FROM tb_paquetes");
  
   
   
   
$p="data";
   
$raro "Escuelas de Iniciacion";
   if(isset(
$p)){
       
       switch(
$raro){
           case 
'Escuelas de Iniciacion':
          
$html="<select>";  
            while(
$row mysql_fetch_array ($buscando)){
             
             
$var $row['duracion_paquete'];
             
$html.= "<option>".$var."</option>";
             
            }
            
$html.="</select>";
            echo 
$html;
            break;
            exit;
            
            
            
       }
   }
   
?>