Print tables in Php form


Well, it happens that when trying to show the table "client" in my php form it is not generated, the problem is that it does not give me the origin of error. I've been looking for that error for a couple of hours and I can not find it. I have theories that the error is given to me by the


but I do not know how else I can print the data

    include("coneccion.php");//Contiene la coneccion a la base de datos, funciona bien la estoy usando en otra parte de la pagina web.


        $sql="select 'cedula', 'nombre', 'direccion', 'telefono' FROM 'cliente' ";
        $rsql= mysqli_query($conn,$sql) or die (mysql_error());

    echo"<form action=index.php#clients method=post>";       
    echo "<table id='tabla3'> <tr>";
        echo "<th>Cedula</th>";
        echo "<th>Nombre</th>";
        echo "<th>Direccion</th>";
        echo "<th>Telefono</th>";
        echo"<input type=submit name=mostrar value=Obtener Datos>";//Pulsa el boton para "generar tabla"
    echo "</tr>";
        echo "<table id='tabla4'>";
        while($row = mysqli_fetch($rsql)){
                echo "<td>";
                    echo $row['cedula'];
                echo "</td>";
                echo "<td>" ;
                    echo $row['nombre'];
                echo "</td>";
                echo "<td>";
                    echo $row['direccion'];
                echo "</td>";
                echo "<td>";
                    echo $row['telefono'];
                echo "</td>";
asked by inusui 17.10.2018 в 20:31

2 answers


In your sql you have the name of the table in single quotes, that gives an error, the query should have more this way:

SELECT 'cedula', 'nombre', 'direccion', 'telefono' FROM cliente; 

Anyway that query will return the strings 'cedula', 'name', 'address', 'telefono' once for each row of the table.
If you want to get the data from the table then you should put them as fields names, i.e. without single quotes:

SELECT cedula, nombre, direccion, telefono FROM cliente; 
answered by 17.10.2018 в 20:43

Have you tried mysqli_fetch_row ? this function is designed to return an iterable element which can be traversed within the while.

answered by 17.10.2018 в 20:41