Ver Mensaje Individual
  #4 (permalink)  
Antiguo 10/10/2011, 03:37
Avatar de MarioAlejandroCR2
MarioAlejandroCR2
 
Fecha de Ingreso: mayo-2010
Ubicación: Esparza - Puntarenas
Mensajes: 98
Antigüedad: 14 años
Puntos: 2
Respuesta: Solo imprime el ultimo id en un while de una consulta lo demás si se impri

Cita:
Iniciado por MarioAlejandroCR2 Ver Mensaje
Tengo este código que te hace selleccionar una fecha y selecciona todos los campos de una tabla calendario cuando la fecha es igual a la digitada, hasta acá funciona bien:

Código PHP:
Ver original
  1. <?php
  2. $Accion_Formulario = $_SERVER['PHP_SELF'];
  3. if ((isset($_POST["OC_selec1"])) && ($_POST["OC_selec1"] == "formsf")) {
  4. $SQL = sprintf("select * from calendario where dia='".$_POST['dia']."' and mes='".$_POST['mes']."' and anho='".$_POST['anho']."'");
  5.  
  6. mysql_select_db($Basedatos, $MiConexion);
  7. $regis2 = mysql_query($SQL, $MiConexion) or die(mysql_error());
  8. $row_regis2= mysql_fetch_assoc($regis2);
  9. }
  10. ?>

El problema se da ya casi, acá, imprime bien todos que seon de dicha fecha en los campos mediante un while, y hay un botón seleccionar que captura el idcal (id del calendario)

Código PHP:
Ver original
  1. <form method="post" name="formse" onsubmit="return checkdata(this)" action="<?php echo $Form_SelEv; ?>" >
  2. <?php
  3. $row_regis2 = mysql_query($SQL, $MiConexion);
  4. while($cateFila = mysql_fetch_assoc($row_regis2)){
  5.         $ideven = $cateFila['idcal'];
  6.         echo '<br /><div class="nar"><b>Evento: </b>',$cateFila['nomgral'],'</br>
  7.         <b>ID: </b>',$cateFila['idcal'],'
  8.         <input type="submit" value="Seleccionar" name="enviar" class="whiteder"></input>
  9.         <input type="hidden" name="OC_selec2" value="formse"></input>
  10.         </div>';
  11.         echo '<hr color="#e1e1e1"></hr>';
  12.            
  13. }?>

Consulta que debería tomar idcal
Código PHP:
Ver original
  1. <?php
  2. $Form_SelEv = $_SERVER['PHP_SELF'];
  3. if ((isset($_POST["OC_selec2"])) && ($_POST["OC_selec2"] == "formse")) {
  4. $SQLSE = sprintf("select * from calendario where idcal='".$ideven."'");
  5.  
  6. mysql_select_db($Basedatos, $MiConexion);
  7. $regisse = mysql_query($SQLSE, $MiConexion) or die(mysql_error());
  8. $row_regisse= mysql_fetch_assoc($regisse);
  9. }
  10. ?>
  11.  
  12.        
  13.         </form>

El problema es que solo me imprime el último valor del while, lo comprobe haciendo un echo a $ideven, pero a la hora de hacerle un echo al $SQLSE osea la consulta me sale:
Código Resultado:
Ver original
  1. select * from calendario where idcal=''

Última edición por MarioAlejandroCR2; 10/10/2011 a las 03:54