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.

Recommended Answers

All 4 Replies

Searching at web you can see good solutions at this Click Here

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.

Member Avatar

I noticed a new thread: https://www.daniweb.com/web-development/php/threads/499821/table-generation on a similar theme. Hmmm. Maybe try to keep it together since members may be actively posting here and you've moved on in a different thread. If that's the case, mark this solved and use the other thread. If not, explaain in greater detail what you need that is not related to your new thread. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.