Wrapping SQL results in 2 tables

From: Date: Tue, 21 Jan 2003 19:29:14 +0000
Subject: Wrapping SQL results in 2 tables
Groups: php.general 
Request: Send a blank email to php-general+get-132497@lists.php.net to get a copy of this message
I'm trying to present a phone directory in a printable format that will make "most" people happy. What I need to do is take the results from our database and "break" it into two tables. ie. <table> Extension FName LName Dept. ...25x </table> <table> Extension FName LName Dept. ...Records 26+ </table> This is what I have done without success: $result = mssql_query($sql); echo "<table border=1>\n"; echo "<tr>\n"; echo "<td>Extension\n"; echo "</td>\n"; echo "<td>First Name\n"; echo "</td>\n"; echo "<td>Last Name\n"; echo "</td>\n"; echo "<td>Dept.\n"; echo "</td>\n"; echo "</tr>\n"; while($row = mssql_fetch_array($result)) { $n++; echo "<tr>\n"; echo "<td>$row[0]\n"; echo "</td>\n"; echo "<td>$row[1]\n"; echo "</td>\n"; echo "<td>$row[2]\n"; echo "</td>\n"; echo "<td>$row[3]\n"; echo "</td>\n"; echo "</tr>\n"; If ($n==40) { echo "</table>\n"; echo "<br>"; echo "<table border=1>\n"; echo "<tr>\n"; echo "<td>$row[0]\n"; echo "</td>\n"; echo "<td>$row[1]\n"; echo "</td>\n"; echo "<td>$row[2]\n"; echo "</td>\n"; echo "<td>$row[3]\n"; echo "</td>\n"; echo "</tr>\n"; } else { } } echo "</table>\n"; It successfully closes that table after 40 records, but the remaining records are at the bottom of the page. What I'd like to end up with is 2 columns with 40 records in each column Ext. FName LName Dept. | Ext. FName LName Dept. 1 41 ... ... 40 Any help is appreciated.

« previous php.general (#132497) next »