Ver Mensaje Individual
  #6 (permalink)  
Antiguo 16/07/2015, 19:10
Avatar de xfxstudios
xfxstudios
 
Fecha de Ingreso: junio-2015
Ubicación: Valencia - Venezuela
Mensajes: 2.448
Antigüedad: 8 años, 10 meses
Puntos: 263
Respuesta: No puedo mostrar los datos desde mysql en una tabla

con mysqli:
Código PHP:
Ver original
  1. <?php
  2. $db = new mysqli(tu host, tu user, tu pass, tu base);
  3.  
  4. $search = '';
  5. if (isset($_POST['search'])){
  6.     $search = $_POST['search'];
  7. }
  8. $consulta = $db->query("SELECT * FROM alumnos WHERE nombre = '$search'") ;
  9. $totalRows = mysqli_num_rows($consulta);
  10. ?>
  11.  
  12. <?php if ($resultado>0 && $search!='') {?>
  13. <h2>REGISTROS</h2>
  14. <?php  
  15. echo "<table>";  
  16. echo "<tr>";  
  17. echo "<th>Nombre</th>";  
  18. echo "<th>edad</th>";  
  19. echo "<th>Pais</th>";  
  20. echo "</tr>";  
  21. while ($fila = $resultado -> fetch_array()){    
  22.     echo "<tr>";  
  23.     echo "<td>".$fila['nombre']."</td>";  
  24.     echo "<td>".$fila['apellido']."</td>";  
  25.     echo "<td>".$fila['nit']."</td>";  
  26.     echo "</tr>";  
  27. }
  28.  echo "</table>"; ?>
  29. <?php } ?>