Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/05/2016, 18:49
kukiko11
 
Fecha de Ingreso: diciembre-2015
Mensajes: 115
Antigüedad: 8 años, 4 meses
Puntos: 2
Pregunta tabla dinamica siempre me devuelve el mismo registro en vez de todos?

quiero cargar los registros dinamicamente en una tabla mediante php pero el codigo solo me muestra el mismo registro (el primero) tantas veces como registros haya en la tabla, en que estoy fallando?

Código PHP:
<?php 
require('db_conexion.php');
$show_posts=$conexion->query("SELECT id_post,titulo,fecha,leido FROM post ORDER BY id_post DESC");
if (
$show_posts->num_rows==0) {
    echo 
"No hay ningun post registrado hasta el momento...";
}else{
    while (
$posts$show_posts->fetch_array()) {
        
$post=$posts['titulo'];
        
$readed=$posts['leido'];
        
$date=$posts['fecha'];

        
$info'<tbody>
           <tr>
             <td>'
.$post.'</th>
             <td>'
.$readed.'</td>
             <td>'
.$date.'</td>
             <td>editar - eliminar</td>
           </tr>
        </tbody>'

}
}
?>
Código HTML:
Ver original
  1. <section class="admin-posts">
  2. <table border="1">
  3.         <caption>Administrar Posts</caption>
  4.  
  5.         <colgroup>
  6.            <col />
  7.            <col />
  8.            <col />
  9.         </colgroup>
  10.  
  11.         <thead>
  12.            <tr>
  13.              <th scope="col">Post</th>
  14.              <th scope="col">Leido</th>
  15.              <th scope="col">Fecha</th>
  16.              <th scope="col">Admin</th>
  17.            </tr>
  18.         </thead>
Código PHP:
Ver original
  1. <?php  for($i=0;$i<$show_posts->num_rows;$i++){
  2.         echo $info;
  3.         } ?>
  4. </table>