I
I
IgorPlays2021-07-28 22:14:48
PHP
IgorPlays, 2021-07-28 22:14:48

how to populate html table using php?

I have a table in html

<table class="table" disabled>
                <thead>
                    <tr>
                        <th style="text-align: center; color:#66bb6a;" width="250">Ф</th>
                        <th style="text-align: center; color:#66bb6a;" width="250">И</th>
                        <th style="text-align: center; color:#66bb6a;" width="250">ОE</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                    </tr>
                </tbody>
            </table>


and the cycle that was supposed to fill it

for($i = 0; $i < sizeof($fioList); $i++)
    {
            echo '
                        <td>'.$leadLists[$i]['f'].'</td>
                        <td>'.$leadLists[$i]['i'].'</td>
                        <td>'.$leadLists[$i]['o'].'</td>
            ';

    }


But they just go to the page and not to the table

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
IgorPlays, 2021-07-28
@IgorPlays

add php code to html table

<tbody>
                        <?php 
                                for($i = 0; $i < sizeof($fio); $i++)
    {
                                    echo '  
                                            <tr>
                                                <td>'.$leadLists[$i]['f'].'</td>
                                                <td>'.$leadLists[$i]['i'].'</td>
                                                <td>'.$leadLists[$i]['o'].'</td>
                                            </tr>
                                    ';

    }
                         ?>
                </tbody>
            </table>

A
amg0461, 2021-07-29
@amg0461

The php code inserts the result of its work in the place where it is written . If this php code is inside your html table, it will insert the result there (which is what you want). If this code is somewhere else, it will insert it in another place, and the browser will display it outside the table, of course.

O
Oleg Frolov, 2021-07-29
@Digiport

Use a template engine - the 21st century is in the yard!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question