0

Hi,could anyone tell me please what is the most common and good way to create HTML table from php array.And how to fill it with randomly generated numbers.? Regarding the table so many posts online,but which is the best approach?Thanks.

5
Contributors
4
Replies
24
Views
1 Year
Discussion Span
Last Post by diafol
0

There is a foreach(). However such opeartion forces you to know the amounts of rows (3 in example) and the keys for each row ("userid", "username", "email").

foreach ($myArray as $theCurrentRow) {
    echo "<td>" . $theCurrentRow["userid"] . "</td><td>" . $theCurrentRow["username"] . "</td><td>" . $theCurrentRow["email"] . "</td>";
}

Just wrap it in <table> and <tr>'s and you have script that will automatically create a new row with, every, single, record.

Edited by Aeonix

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.