Ver Mensaje Individual
  #3 (permalink)  
Antiguo 23/06/2011, 20:18
Avatar de totti026
totti026
 
Fecha de Ingreso: junio-2011
Mensajes: 150
Antigüedad: 12 años, 10 meses
Puntos: 4
Pregunta Respuesta: Undefined index y Undefined variable

Código PHP:
Ver original
  1. <?php
  2. include("conexion.php");
  3.  
  4. //===================== CREAMOS FILTRO DE BUSQUEDA =========================
  5. if ($_GET["busqueda"]!="") //Si se ha escrito algo para buscar
  6. {
  7.     if (is_string($_GET["busqueda"]))
  8.         $filtro = " and (nombre_residente like '%". $_GET["busqueda"] ."%' or correo_electronico=". $_GET["busqueda"] .")" ;
  9.     else
  10.         $filtro = " and (nombre_residente like '%". $_GET["busqueda"] ."%' or correo_electronico like '%". $_GET["busqueda"] ."%')" ;  
  11.     $enlace="<a href='consultaresidentesisistemas.php?num=1' title='Clic para ver todos los Residentes'>Mostrar todos</a>";
  12. }
  13.     //===================== FIN FILTRO DE BUSQUEDA =========================
  14.  
  15. //Consultamos la tabla isistemas
  16. $fila_campos=mysql_query("SELECT * FROM isistemas WHERE nombre_residente=nombre_residente ". $filtro .";",$conexion);
  17. //Averiguamos cuántos registros devolvió la consulta anterior.
  18. $numero_reg=mysql_num_rows($fila_campos);
  19.  
  20. //============== VERIFICAR RESULTADOS DE LA BUSQUEDA O CONSULTA ==================
  21. if ($numero_reg==0 && $_GET["busqueda"]=="")
  22. { //Si no buscamos nada y la consulta arrojó CERO productos, mostrar mensaje.
  23.     echo mostrar_mensaje_error("Sin registros","No se encontro; ningun registro en la base de datos","","<a href='ISistemas.php'>Ingresar nuevo Residente</a>");
  24.     exit();
  25. } elseif ($numero_reg==0){ //Mensaje para mostrar
  26.     $mensaje_registros="<font color='red'>No se han hallado registros con el criterio: <strong>". $_GET["busqueda"] ."</strong></font>";
  27. } elseif ($_GET["busqueda"]!=""){//MEnsaje para mostrar
  28.     $mensaje_registros="<font color='blue'>Registros hallados con el criterio '<strong>". $_GET["busqueda"] ."</strong>': ". $numero_reg ."</font>";
  29. } else {
  30.     $mensaje_registros="Registros en la base de datos: ". $numero_reg;
  31. }
  32. //============== FIN VERIFICAR RESULTADOS DE LA BUSQUEDA O CONSULTA ==================
  33.  
  34. //============== GESTIONAR PAGINACION =============================
  35. $numero_reg=mysql_num_rows($fila_campos);
  36. $registros = 5;
  37. $pagina = $_REQUEST["num"];
  38.  
  39. if (!$pagina) {
  40.     $inicio = 0;
  41.     $pagina = 1;
  42. }
  43. else {
  44.     $inicio = ($pagina - 1) * $registros;
  45. }
  46. //============== FIN PAGINACION =============================
  47.  
  48. //Consulta con limit que permite paginar
  49. $fila_campos=mysql_query("SELECT * FROM isistemas WHERE nombre_residente=nombre_residente ". $filtro ." LIMIT $inicio,$registros;",$conexion);
  50. $total_paginas = ceil($numero_reg / $registros);
  51.  
  52. ?>
  53. <html>
  54. <head>
  55. <title>Consulta</title>
  56. <style type="text/css">
  57. .ms-simple1-main {
  58.     border-left-style: none;
  59.     border-right-style: none;
  60.     border-top: 1.5pt solid green;
  61.     border-bottom: 1.5pt solid green;
  62. }
  63. .ms-simple1-tl {
  64.     border-left-style: none;
  65.     border-right-style: none;
  66.     border-top-style: none;
  67.     border-bottom: .75pt solid green;
  68. }
  69. .ms-simple1-top {
  70.     border-left-style: none;
  71.     border-right-style: none;
  72.     border-top-style: none;
  73.     border-bottom: .75pt solid green;
  74. }
  75.  
  76. *
  77. {
  78. padding: 0em;
  79. margin: 0em;
  80. }
  81.  
  82. *
  83. {
  84. padding: 0em;
  85. margin: 0em;
  86. }
  87.  
  88. .auto-style7 {
  89.     text-align: right;
  90. }
  91.  
  92. .auto-style8 {
  93.     font-family: Aharoni;
  94.     font-size: medium;
  95.     color: #00FF00;
  96. }
  97.  
  98. .auto-style9 {
  99.     font-family: Aharoni;
  100. }
  101.  
  102. </style>
  103. </head>
  104.  
  105. <body>
  106. <div class="auto-style7">
  107. <br>
  108. <a href="menu2.php">Atras</a><br>
  109. </div>
  110. <form method="get" action="consultaresidentesisistemas.php?num=1">
  111.     <span class="auto-style8">&nbsp;&nbsp;&nbsp;&nbsp; Buscar</span>&nbsp;
  112.  <input name="busqueda" type="text" id="busqueda" style="width: 209px" value="<?php echo $_GET['busqueda'];?>">&nbsp;&nbsp;&nbsp;  
  113.     <input name="btnbuscar" type="submit" id="btnbuscar" value="Buscar" class="auto-style9">&nbsp;&nbsp;&nbsp;
  114.         <span><?php echo $enlace; ?></span><span><?php echo $mensaje_registros ?></span><br>
  115.     <br><hr><br></form><br>
  116. <center>
  117. <table border="0" cellspacing="0" style="width: 100%">
  118.         <tr>
  119.           <th width="150"   ><div align="center" >Nombre Residente</div></th>
  120.           <th width="50"  ><div align="center" >Correo Electronico</div></th>
  121.           <th width="100"  ><div align="center" >Telefono</div></th>
  122.           <th width="100"  ><div align="center" >Nombre del Proyecto</div></th>
  123.           <th width="150"  ><div align="center" >Asesor P/ Residencias</div></th>
  124.           <th width="150"  ><div align="center" >Revisor de Informe Tecnico</div></th>
  125.           <th width="100"  ><div align="center" >Fecha Inicio</div></th>
  126.           <th width="100"  ><div align="center" >Fecha Termino</div></th>
  127.           <th width="100"  ><div align="center" >Fecha Examen</div></th>
  128.           <th width="50"  ><div align="center" >Modificar</div></th>
  129.           <th width="50" ><div align="center" >Eliminar</div></th>
  130.         </tr>
  131.         <?php
  132.    
  133.    
  134.     $color="#E0E0E0";
  135.     while ($fila=mysql_fetch_array($fila_campos))
  136.     {
  137.         if ($color=="#FFFFCC") //claro
  138.             $color="#FFFF9F";
  139.         else
  140.             $color="#FFFFCC";
  141.     ?>
  142.         <tr bgcolor="<?php echo $color; ?>">
  143.           <td>
  144.             <div align="center"><?php  echo $fila["nombre_residente"]; ?></div></td>
  145.           <td>
  146.           <div align="center"><?php  echo $fila["correo_electronico"]; ?></div></td>
  147.           <td>
  148.           <div align="center"><?php  echo $fila["telefono"]; ?></div></td>
  149.           <td>
  150.           <div align="center"><?php  echo $fila["nombre_proyecto"]; ?></div></td>
  151.           <td>
  152.           <div align="center"><?php  echo $fila["asesor"]; ?></div></td>
  153.           <td>
  154.           <div align="center"><?php  echo $fila["revisor"]; ?></div></td>
  155.           <td>
  156.           <div align="center"><?php  echo $fila["fecha_inicio"]; ?></div></td>
  157.           <td>
  158.           <div align="center"><?php  echo $fila["fecha_termino"]; ?></div></td>
  159.           <td>
  160.           <div align="center"><?php  echo $fila["fecha_examen"]; ?></div></td>
  161.           <td><div align="center"><a onClick="window.open('modificarISistemas.php?nomres=<?php echo $fila["nombre_residente"]; ?>&num=<?php echo $_GET["num"]; ?>','Modificar','width=850,height=600,left=250,top=100,menubar=1,toolbar=1,resizable=0,resizable=no,scrollbars=0,scrollbars=yes')" href="javascript:void(0);">Modificar</a></div></td>
  162.           <td><div align="center"><a href="confirmaeliminaresidente.php?nomres=<?php  echo $fila["nombre_residente"]; ?>&num=<?php echo $_GET["num"]; ?>" title="Clic para eliminar <?php echo $fila["nombre_residente"]; ?>">Eliminar</a></div></td>
  163.         </tr>
  164.         <?php
  165.     }
  166.     ?>
  167.        
  168.       </table><?php
  169.  
  170.     //Pagina Anterior
  171.     if(($pagina - 1) > 0) {
  172.         echo "<a href='consultaresidentesisistemas.php?num=".($pagina-1)."'>< Anterior</a> ";
  173.         }
  174.     //Listado de paginas
  175.     if ($total_paginas>1)
  176.     {
  177.         for ($i=1; $i<=$total_paginas; $i++){
  178.             if ($pagina == $i) {
  179.                 echo "<b><font color='#FF0000' size='3'>".$pagina."</font></b> ";
  180.             } else {
  181.                 echo "<a href='consultaresidentesisistemas.php?num=$i'>$i</a> ";
  182.             }
  183.         }
  184.     }
  185.     //Pgina Siguiente
  186.     if(($pagina + 1)<=$total_paginas) {
  187.         echo " <a href='consultaresidentesisistemas.php?num=".($pagina+1)."'>Siguiente ></a>";
  188.     }
  189.  
  190. ?>
  191. </center>
  192. </body>
  193. </html>

los errores estan en la linea 5,16,27,49 y 114
Undefined index: busqueda in C:\wamp\www\Sistema\consultaresidentesisistemas.ph p on line 5
Undefined variable: filtro in C:\wamp\www\Sistema\consultaresidentesisistemas.ph p on line 16
Undefined index: busqueda in C:\wamp\www\Sistema\consultaresidentesisistemas.ph p on line 27
Undefined variable: filtro in C:\wamp\www\Sistema\consultaresidentesisistemas.ph p on line 49
Undefined variable: enlace in C:\wamp\www\Sistema\consultaresidentesisistemas.ph p on line 114
gracias!!