note 27574 added to ref.com

From: Date: Wed, 11 Dec 2002 17:23:18 +0000
Subject: note 27574 added to ref.com
Groups: php.notes 
Request: Send a blank email to php-notes+get-40763@lists.php.net to get a copy of this message
Searched for days on how to set up a multi-column html output grid that didn't use an array when creating an ADODB connection. Couldn't find one so I figured it out myself. Pretty simple. Wish I would have tried it myself sooner. Commented code with database connection is below... <html> <body> <table> <?php //create the database connection $conn = new COM("ADODB.Connection"); $dsn = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("mydb.mdb"); $conn->Open($dsn); //pull the data through SQL string $rs = $conn->Execute("select clients from web"); $clients = $rs->Fields(1); //start the multicolumn data output $i = 0; $columns = 5; while (!$rs->EOF){ //if $i equals 0, start a row if($i == 0){ echo "<tr>"; } //then start writing the cells in the row, increase $i by one, and move to the next record echo "<td>" . $clients->value . "</td>"; $i++; $rs->movenext(); //once $i increments to equal $columns, end the row, //and start the process over by setting $i to 0 if($i == $columns || $rs->EOF) { echo "</tr>"; $i = 0; } } //end multicolumn data output //close the ADO connections and release resources $rs->Close(); $conn->Close(); $rs = null; $conn = null; ?> </table> </body> </html> -- http://www.php.net/manual/en/ref.com.php http://master.php.net/manage/user-notes.php?action=edit+27574 http://master.php.net/manage/user-notes.php?action=delete+27574 http://master.php.net/manage/user-notes.php?action=reject+27574

« previous php.notes (#40763) next »