I need to create a table using a variable number of records to insert on it. The number of records comes from a select in my database which returns the value of 3 columns and I store them in 3 vars. For example:
<?php
$connection = Mage::getSingleton('core/resource')->getConnection('core_read');
$sql = $connection->query("SELECT column1, column2, column3 FROM table ");
while ($row = $sql->fetch()) {
$var1[] = $row['column1'];
$var2[] = $row['column2'];
$var3[] = $row['column3'];
}
?>
Let's suppose that I have 4 rows in my table, so each of my vars are going to store 4 records and I need to create something like this in my screen:
*-----------------------------------------------------------*
| var1 record1 | var1 record2 | var1 record3 | var1 record4 |
| var2 record1 | var2 record2 | var2 record3 | var2 record4 |
| var3 record1 | var3 record2 | var3 record3 | var3 record4 |
*-----------------------------------------------------------*
How can I create something like a dynamic table to show my records in an organized way in the screen?
Edit 1:
Just to make it clearer, the table I want to display is in my php page. I don't know how many records the select will return, that's why it should be a dynamic table, but all my 3 vars will ALWAYS have the same amount of records, for example: If my table has 7 rows, then my 3 arrays are going to have 7 records each.
The while loop is also working correctly.