Foros del Web » Programando para Internet » PHP »

Mostrando resultados

Estas en el tema de Mostrando resultados en el foro de PHP en Foros del Web. Hola de nuevo, En mi página tengo un combo dinámico: Código PHP: <form action="consultas.php" method="post" enctype="multipart/form-data"> <select name="comboxedi"> <?php                               $sql  =  "SELECT DISTINCT libro.editorial FROM libro JOIN prestamo ON prestamo.titulo=libro.titulo WHERE prestamo.estado = 'Disponible' ORDER BY libro.editorial;" ;  $QUERY  =  mysql_query (  $sql  ...
  #1 (permalink)  
Antiguo 14/12/2011, 22:36
 
Fecha de Ingreso: julio-2007
Mensajes: 15
Antigüedad: 16 años, 9 meses
Puntos: 0
Pregunta Mostrando resultados

Hola de nuevo,

En mi página tengo un combo dinámico:

Código PHP:

<form action="consultas.php" method="post" enctype="multipart/form-data">
<select name="comboxedi">
<?php 
                           
 $sql 
"SELECT DISTINCT libro.editorial FROM libro JOIN prestamo ON prestamo.titulo=libro.titulo WHERE prestamo.estado = 'Disponible' ORDER BY libro.editorial;"

$QUERY mysql_query$sql ) or die (mysql_error()); 
                            
  echo 
'<option value="0">Seleccione..</option>';
                               
    while( 
$fil mysql_fetch_assoc$QUERY ) ) {
                           
echo 
'<option value="'.$fil['editorial'].'"    >'.$fil['editorial'].'</option>';
                                    

           
?>
</select>
 <input name="enviar" type="submit" value="enviar" />
</form>

Para el cual capturo via POST el resultado del mismo


Luego tengo esta tabla:

Código PHP:
<table id="librosxedit" width="475" border="1" style="text-align:center;">
                <tr> 
                    <th scope="col">Titulo</th>
                    <th scope="col">Estado</th>
                </tr>
                  
                    
        <?php $sql "SELECT libro.titulo, prestamo.estado FROM libro JOIN prestamo ON prestamo.titulo = libro.titulo WHERE prestamo.estado = 'Disponible' AND libro.editorial = '$valor'  ORDER BY libro.titulo; ";
    
$QUERY mysql_query$sql ) or die (mysql_error()); 
                    
while ( 
$fil mysql_fetch_assoc($QUERY) ) { ?>
                            
<tr>
<td><?php echo $fil['titulo']; ?></td>
<td><?php echo $fil['estado']; ?></td>
            
 <?php }?>
                 
 </tr>
</table>

Lo que me gustaria hacer es que si la opcion por defecto esta seleccionada, no muestre nada en la tabla pero si selecciona uno de los valores disponibles, hace la consulta y actualiza los campos con los datos correspondientes..

Me pasa que la tabla esta tomando un valor por defecto que nunca seleccione
  #2 (permalink)  
Antiguo 14/12/2011, 23:47
Avatar de mko
mko
 
Fecha de Ingreso: agosto-2010
Ubicación: la vida es un riesgo
Mensajes: 101
Antigüedad: 13 años, 8 meses
Puntos: 14
Respuesta: Mostrando resultados

pruba con el evento onChange de java script


algo como

Código PHP:

<form action="consultas.php" method="post" enctype="multipart/form-data">
<select name="comboxedi"  onChange="consulta()">
<?php 
                           
 $sql 
"SELECT DISTINCT libro.editorial FROM libro JOIN prestamo ON prestamo.titulo=libro.titulo WHERE prestamo.estado = 'Disponible' ORDER BY libro.editorial;"

$QUERY mysql_query$sql ) or die (mysql_error()); 
                            
  echo 
'<option value="0">Seleccione..</option>';
                               
    while( 
$fil mysql_fetch_assoc$QUERY ) ) {
                           
echo 
'<option value="'.$fil['editorial'].'"    >'.$fil['editorial'].'</option>';
                                    

           
?>
</select>
 <input name="enviar" type="submit" value="enviar" />
</form>

CON ESTO CADA QUE ELIGAS UNA OPCION DEL SELECT SE EJECUTARA LA FUNCION
ESTA ES UNA IDEA
__________________
cuando no esperas nada y obtienes todo eso es destino

Última edición por mko; 14/12/2011 a las 23:58

Etiquetas: mysql
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:24.