hi.
I am trying to split results from mysql into two columns sorted vertically an example is:
A N
Apple Nopplefruit
B O
Banana Orange
Im trying to get a similar result to:
http://www.tooled-up.com/manufacturer.asp but failing miserably,
here is my code:
columns = 2;
$rows = ceil($totalmanu / $columns);
while($row = mysql_fetch_array($result)) {
$data[] = $row['manufacturer'];
}
echo "<table border=\"1\" align=\"center\" width=\"400px\">\n";
for($i = 0; $i < $rows; $i++) {
echo "<TR>\n";
for($j = 0; $j < $columns; $j++) {
if(isset($data[$i + ($j * $rows)])) {
echo "<td>";
if ($row = mysql_fetch_array($result)) {
$currentletter = "0";
do {
$manufacturer = $row["manufacturer"];
$initial = substr($manufacturer,0,1);
if ($currentletter != $initial)
{
$currentletter = $initial;
echo "\n<p><b><a name=\"$initial\">";
echo "$initial</a></b></p>\n";
}
echo " " . $data[$i + ($j * $rows)] . " \n";
echo "</td>";
} while ($row = mysql_fetch_array($result));
}
}
echo "</tr>\n";
}
}
echo "</table>\n";
please can someone help? It's driving me mad!