Ver Mensaje Individual
  #15 (permalink)  
Antiguo 21/07/2015, 15:25
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: Almacenar datos de una sentencia en un array php

aqui muestras los registros numerados en una tabla:

Código PHP:
Ver original
  1. <?php
  2.  
  3. $mysqli = new mysqli(" host ", "user", "pass", "bd");
  4.  
  5. if ($mysqli->connect_errno) {
  6. echo "Fallo al contenctar a MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;
  7. }
  8.  
  9. $consulta = "SELECT email from emails where activo = 0 " ;
  10.  
  11. $resultado = $mysqli->query($consulta) ;
  12.  
  13. //aqui creo el array
  14.  
  15. //creo una tabla
  16. echo    "<table>";
  17. echo        "<tr><th>Nº</th><th>Email</th></tr>";
  18.  
  19. //inicio el contador
  20. $con=0;
  21.  
  22. //inicio el array
  23. while ($fila = $resultado->fetch_array()) {
  24.  
  25. //celda que se repite con los registros
  26. echo "<tr><td>".$con."</td><td>".$fila['email']."</td></tr>";
  27.  
  28. $con++;
  29. }
  30.  
  31. //cierro la tabla
  32. echo "</table>";
  33.  
  34. ?>
__________________
[email protected]
HITCEL