I have a list of names, emails and messages that I want to show, my problem is that when you show it, only the first of the records is displayed and it is repeated many times.
I attach the code:
<?php
//Conectar con el servidor
$link=mysqli_connect('localhost','USER','PASS');
if(!$link){
echo'No se pudo establecer conexion con el servidor:'.mysql_error();
}else{
//Seleccionamos Base de datos
$base=mysqli_select_db($link, 'DATABASE');
if(!$base){
echo'No se encontro la base de datos:'.mysqli_error();
}else{
//Sentencia SQL
$sql= "SELECT * FROM datos";
$ejecuta_sentencia = mysqli_query($link, $sql);
if(!ejecuta_sentencia){
echo'Hay un error en la sentencia SQL:' .mysqli_error();
}else{
//Traer los resultados como array para poder imprimir
$lista_usuarios = mysqli_fetch_array($ejecuta_sentencia);
if(!lista_usuarios){
echo'Error al mostrar lista de usuarios:' .mysqli_error();
}
}
}
}
?>
<!DOCTYPE html>
<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=gb18030">
<title>Listado de Usuarios</title>
<link rel="stylesheet" type="text/css" href="estilo.css">
</head>
<body>
<h1>Mostrando Usuarios desde Base de Datos</h1>
<table>
<tr>
<th>Nombres</th>
<th>Correo Electronico</th>
<th>Mensaje</th> <?php
while($row=mysqli_fetch_array($ejecuta_sentencia))
for($i=1; $i<$lista_usuarios; $i++)
{
echo"<tr>";
echo"<td>".$row['nombres']."</td>";
echo"<td>".$row['email']."</td>";
echo"<td>".$row['message']."</td>";
echo"<td></td>";
echo"</tr>";
}
?>
<tr>
</table>
</body>
</html>
I am starting in the world of PHP, I would appreciate your enormous help.