I'll admit I'm a novice, but this is what I would do:
$i = 1;
$sql = "select * from tablename";
$result = mssql_query($sql, $connection);
while ($row = mssql_fetch_array($result)) {
$array_1[$i] = array("col1" => $row['col1'],
"col2" => $row['col2'],
"col3" => $row['col3'],
"col4" => $row['col4'],
"col5" => $row['col5'],
"col6" => $row['col6'],
"col7" => $row['col7'],
"col8" => $row['col8'],
"col9" => $row['col9'],
"col10" => $row['col10']);
$array_2[$i] = array("col11" => $row['col11'],
"col12" => $row['col12'],
"col13" => $row['col13'],
"col14" => $row['col14'],
"col15" => $row['col15'],
"col16" => $row['col16'],
"col17" => $row['col17'],
"col18" => $row['col18'],
"col19" => $row['col19'],
"col10" => $row['col10']);
$i++;
}
# Now create the table:
echo "<table border=1>";
echo "<tr>";
echo "<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>";
echo "</tr>";
foreach ($array_1 as $new_array1) {
echo "<tr>";
foreach ($new_array1 as $col) {
echo "<td>" . $col . "</td>";
}
echo "</tr>";
}
echo "<tr>";
echo "<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
<th>Column 4</th>
<th>Column 5</th>
<th>Column 6</th>
<th>Column 7</th>
<th>Column 8</th>
<th>Column 9</th>
<th>Column 10</th>";
echo "</tr>";
foreach ($array_2 as $new_array2) {
echo "<tr>";
foreach ($new_array2 as $col) {
echo "<td>" . $col . "</td>";
}
echo "</tr>";
}
What this does is create two arrays, one with results from the first 10 columns, and another with the results for the last 10 columns.
Then start a table, and cycle through the first array to create the rows for the first part, then cycle through the second array to create the results for the second part.
You could also combine those two arrays into one big one if you wanted two. It's a little more indepth and is less typing, but may be a little more confusing as well.
Also, it's pretty much the same code if you're using MySql; just change all the mssql to mysql.