Ver Mensaje Individual
  #12 (permalink)  
Antiguo 30/01/2015, 08:00
Avatar de Carlos1975
Carlos1975
 
Fecha de Ingreso: mayo-2005
Mensajes: 29
Antigüedad: 19 años
Puntos: 0
Respuesta: Consulta php y mysql. Repite datos.

prueba esto:


Código PHP:
Ver original
  1. <?php session_start(); ?>
  2.  
  3. <html>
  4.  
  5. <head><title>Página privada alumnos y profesores.</title></head>
  6.  
  7. <body class="fondo">
  8.     <div id="menu">
  9.       <asp:Repeater ID="MenuItems" runat="server">
  10.           <ItemTemplate>
  11.              
  12. <?php
  13.  
  14. if ((isset($_SESSION['k_username'])) && ($_SESSION['k_username'] != "")) {
  15.    
  16.     $link = mysql_connect ("localhost", "root","root");
  17.     $conex = mysql_select_db("examen",$link);
  18.     $usuario = "email";
  19.     $sql = "SELECT * FROM persona WHERE email = ".$usuario."";
  20.            
  21.     $result = mysql_query($sql,$link);
  22.     $reg = mysql_fetch_array($result);
  23.    
  24.     while ($reg = mysql_fetch_array($result)) {
  25.    
  26.     // lo que tengas que repetir en forma de bucle
  27.    
  28.     }
  29.        
  30.     echo "<table border='1' text-align='center'>";
  31.     echo "<tr>";
  32.     echo "<td>Bienvenido, ".$_SESSION['ncompleto']."</td>";
  33.     echo "<td><a href='logout.php'>(Salir)</a></td>";
  34.     echo "</tr>";
  35.     echo "<tr><td colspan='2' align='center'>Examenes</td></tr>";
  36.     echo "<tr>";
  37.     echo "<td><input type='button' value='Ver examenes.' onclick='window.location.href='examenes/verexamenes.php''/></td>";
  38.     echo "<td><input type='button' value='Agregar examenes.' onclick='window.location.href='examenes/altas/formAltasDeExamenes.php''/></td>";
  39.     echo "</tr>";
  40.     echo "<tr><td colspan='2' align='center'>Personas</td></tr>";
  41.     echo "<tr>";
  42.     echo "<td><input type='button' value='Ver personas.' disabled /></td>";
  43.     echo "<td><input type='button' value='Agregar personas.' onclick='window.location.href='persona/altaspersona/altapersona.htm''/></td>";
  44.     echo "</tr>";
  45.     echo "<tr><td colspan='2' align='center'>Profesores</td></tr>";
  46.     echo "<tr>";
  47.     echo "<td><input type='button' value='Ver profesores.' disabled /></td>";
  48.     echo "<td><input type='button' value='Agregar profesores.' disabled /></td>";
  49.     echo "</tr>";
  50.     echo "<tr><td colspan='2' align='center'>Alumnos</td></tr>";
  51.     echo "<tr>";
  52.     echo "<td><input type='button' value='Ver alumnos.' disabled /></td>";
  53.     echo "<td><input type='button' value='Agregar alumnos.' disabled /></td>";
  54.     echo "</tr>";
  55.     echo "<tr><td colspan='2' align='center'>Grupo</td></tr>";
  56.     echo "<tr>";
  57.     echo "<td><input type='button' value='Ver grupos.' disabled /></td>";
  58.     echo "<td><input type='button' value='Agregar grupos.' disabled /></td>";
  59.     echo "</tr>";
  60.     echo "<tr><td colspan='2' align='center'>Instituto.</td></tr>";
  61.     echo "<tr>";
  62.     echo "<td><input type='button' value='Ver instituto.' disabled /></td>";
  63.     echo "<td><input type='button' value='Agregar instituto.' disabled /></td>";
  64.     echo "</tr>";
  65.     echo "</table>";
  66.          
  67.     echo "<div class='fecha'>";
  68.         echo "Hoy es ";
  69.         echo date("l ");
  70.         echo date("d ");
  71.         echo "de ";
  72.         echo date("F ");
  73.         echo "de ";
  74.         echo date("Y");
  75.     echo "</div>";
  76.                        
  77.     mysql_close ($link);
  78.    
  79. } else {
  80.        
  81.     $updateGoTo = "login.php";
  82.     if (isset($_SESSION['k_username'])) {
  83.         $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
  84.         $updateGoTo .= $_SESSION['k_username'];
  85.     }
  86.     header(sprintf("Location: %s", $updateGoTo));
  87. }
  88.        
  89. ?>
  90.      
  91.              </ItemTemplate>
  92.         </asp:Repeater>
  93.     </div>
  94. </body>
  95.  
  96. </html>