Ver Mensaje Individual
  #5 (permalink)  
Antiguo 10/07/2012, 06:27
skyspablo
 
Fecha de Ingreso: julio-2012
Ubicación: Asunción
Mensajes: 54
Antigüedad: 11 años, 10 meses
Puntos: 3
Respuesta: Mostrar informacion de varias tablas con un juego de registros

Código PHP:
Ver original
  1. <?php
  2. $hostname_connected = "localhost";
  3. $database_connected = "nombre_basededatos";
  4. $username_connected = "root";
  5. $password_connected = "";
  6. $connected = mysql_pconnect($hostname_connected, $username_connected, $password_connected);
  7. #Conectando con tu base de datos
  8. ?>
  9.  
  10. <?
  11.     #definiendo la variable
  12.     if(isset($_GET['dias']))
  13.     {
  14.         $dia_elegido = $_GET['dias'];
  15.     #realizando la consulta sql
  16.     $consultasql = "SELECT * FROM '$dia_elegido' ORDER BY fecha DESC";
  17.     $rsTABLA = mysql_query($consultasql, $connected) or die(mysql_error());
  18.     $row_TABLA = mysql_fetch_assoc($rsTABLA);
  19.     $totalrow_TABLA = mysql_num_rows($rsTABLA);
  20.  
  21.     }
  22. ?>
Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  4. <title>Ejemplo para FDW</title>
  5. </head>
  6.  
  7. <!-- Formulario de filtro -->
  8. <form action="#" method="get">
  9. <select name="dias">
  10. <option value="rol_lunes">Lunes</option>
  11. <option value="rol_martes">Martes</option>
  12. <option value="rol_miercoles">Miercoles</option>
  13. <option value="rol_jueves">Jueves</option>
  14. <option value="rol_viernes">Viernes</option>
  15. <option value="rol_sabado">Sabado</option>
  16. <option value="rol_domingo">Domingo</option>
  17. </form>
  18. <hr />
  19. <?  if(isset($_GET['dias'])){?>
  20.         <table border="0" cellpadding="0" cellspacing="0" width="95%" >
  21.           <tr>
  22.             <td><strong>Jornada</strong></td>
  23.             <td><strong>Partido</strong></td>
  24.             <td><strong>Fecha</strong></td>
  25.             <td ><strong>Hora</strong></td>
  26.             <td>&nbsp;</td>
  27.           </tr>
  28.           <?php do { ?>
  29.             <tr>
  30.               <td><?php echo $row_TABLA['jornada']; ?></td>
  31.               <td><?php echo $row_TABLA['partido']; ?></td>
  32.               <td><?php echo $row_TABLA['fecha']; ?></td>
  33.               <td><?php echo $row_TABLA['hora']; ?></td>
  34.             </tr>
  35.        
  36.             <?php } while ($row_TABLA = mysql_fetch_assoc($rsTABLA)); ?>
  37.         </table>
  38. <? ;}?>
  39. </body>
  40. </html>