how to make dynamic table php sql server

0

Good afternoon:

I AM REALIZING A DYNAMIC TABLE BETWEEN PHP AND SQL SERVER .But no error comes out but I have a record in the DB but they are not reflected in the table it comes out empty

THIS IS MY CURRENT CODE:

   <?php
                $sql = "EXEC AGE_Mantenimiento_Institucion 1,'2',''";

                $result = sqlsrv_query($conn,$sql) or die("Couldn't execut query");

                if (($result)||(sqlsrv_errors == 0))
                {
                    echo "<table width='100%' class='table table-bordered'><thead><tr>
                    <th scope='col'>#</th>
                    <th scope='col'>Año Electivo</th>
                    <th scope='col'>Institucion</th>
                    <th scope='col'>Actualizar</th>
                    ";
                    $i = 0;
                    if (sqlsrv_num_rows($result)>0)
                    {
      //loop thru the field names to print the correct headers
                        echo "</tr></thead>";

//display the data
                        while ($rows = sqlsrv_fetch_array($result,SQLSRV_FETCH_ASSOC))
                        {
                            echo "<tr>";
                            foreach ($rows as $data)
                            {
                                echo "<td align='center'>". $data . "</td>";
                            }
                        }
                    }else{
                        echo "<tr><td colspan='" . ($i+1) . "'>No Results found!</td></tr>";
                    }
                    echo "</table>";
                }else{
                    echo "Error in running query :". sqlsrv_errors();
                }
                ?>
    
asked by PieroDev 05.01.2018 в 20:57
source

0 answers