Ver Mensaje Individual
  #14 (permalink)  
Antiguo 29/07/2009, 12:32
jonatanc
 
Fecha de Ingreso: enero-2009
Mensajes: 408
Antigüedad: 16 años
Puntos: 14
Respuesta: Error! Notice: Undefined index

Hola , ac te paso otro code , probalo :) , hice un par de cambios y correcciones.

Código php:
Ver original
  1. <body>
  2.  
  3. <span class="letras1">Gastos</span>
  4. <br><br>
  5.  
  6. <form name="formulario1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <!-- te jugaste el truco el action :) -->
  7. <table>
  8.   <tr>
  9.     <td>
  10.       <select name="ano" id="ano">
  11.           <option>Año</option>
  12.           <option>2009</option>
  13.           <option>2008</option>
  14.           <option>2007</option>
  15.           <option>2006</option>
  16.       </select>
  17.     </td>
  18.     <td><select name="mes" id="mes">
  19.     <?php
  20.         mysql_connect("localhost", "root", "");
  21.         mysql_select_db("sistema");
  22.           $consulta = "SELECT nombre FROM mes";
  23.         $resultado = mysql_query ($consulta);
  24.         while ($fila = mysql_fetch_array($resultado))
  25.         {
  26.     ?>
  27.         <option value="<?php echo $fila["nombre"]; ?>">
  28.         <?php echo $fila["nombre"]; ?> </option>
  29.         <?php
  30.         }
  31.     ?>
  32.     </select>
  33.     </td>
  34.     <td> <input type="submit" name="Submit" value="Consultar"> </td>
  35.   </tr>
  36. </table>
  37. </form>
  38.  
  39.  
  40.  
  41.  
  42. <table class="tabla">
  43.   <tr class="td">
  44.     <td class="estilocelda2">Categor&iacute;as</td>
  45.     <td class="estilocelda1">Real</td>
  46.     <td class="estilocelda1">%VAR<br>R/R</td>
  47.     <td class="estilocelda1">%COB<br>R/P</td>
  48.     <td class="estilocelda1">GAP<br>R-P</td>
  49.     <td class="estilocelda1">Real</td>
  50.     <td class="estilocelda1">%VAR<br>R/R</td>
  51.     <td class="estilocelda1">%COB<br>R/P</td>
  52.     <td class="estilocelda1">GAP<br>R-P</td>
  53.     <td class="estilocelda1">Ppto</td>
  54.     <td class="estilocelda1">&amp;VAR<br>P/R</td>
  55.   </tr>  
  56.     <?php
  57.     if(isset($_POST)){
  58.     $anio = $_POST["ano"];
  59.     $mess = $_POST["mes"];
  60.     //$anio = (isset($_POST["ano"])? $_POST["ano"]:''); //-- MAL
  61.     $anio=(isset($_POST['anio']))?$_POST['ano']:''; // BIEN
  62.    
  63.     //$mess = (isset($_POST["mes"])? $_POST["mes"]:''); //-- MAL
  64.     $mess=(isset($_POST['mes']))?$_POST['mes']:''; // bien
  65.    
  66.     if($anio=="Año" || $mess=="Mes")
  67.     {
  68.         echo "<script>alert ('Debe Seleccionar Una Fecha')</script>";
  69.         echo "<script>history.back()</script>";
  70.     }
  71.     else
  72.     {
  73.     $consulta = "SELECT valor FROM valorreal WHERE ano='$anio' AND mes='$mess'";
  74.     $resultado = mysql_query($consulta) or die ("Error en consulta:".mysql_error());
  75.     while($datos = mysql_fetch_array($resultado))
  76.     {
  77.         // lo que vaya aca
  78.         }
  79.         }
  80.         }
  81.     ?>