Fwd: [PHP-DB] database result: tables with 2 coloumns

From: Date: Fri, 06 Sep 2002 14:53:05 +0000
Subject: Fwd: [PHP-DB] database result: tables with 2 coloumns
Groups: php.db 
Request: Send a blank email to php-db+get-21608@lists.php.net to get a copy of this message
my improvement is: =============== $counter = 1; echo "<table border=1><tr>"; //start of table for ($i=0;$i<$num_rows; $i++) //loop through the number of records { $row = mysql_fetch_array($result); //Get associate row echo "<td>$row[0]</td>"; //Print out the NAME if($counter =(! $counter)) echo "</tr><tr>"; //Make a new Table row } echo "</tr></table>"; ================ Terry On Thursday, September 5, 2002, at 06:39 PM, Brad Bonkoski wrote:
How's this? (MYSQL example) $query = "select NAME from table_name"; $result = mysql_query($query) or die("Invalid Query: $query"); $num_rows = mysql_num_rows($result); $counter=1; echo "<table border=1><tr>"; //start of table for ($i=0;$i<$num_rows; $i++) //loop through the number of records { $row = mysql_fetch_array($result); //Get associate row echo "<td>$row[0]</td>"; //Print out the NAME if ($counter == 2) { echo "</tr><tr>"; //Make a new Table row $counter=1; //Reset Counter } else { $counter++; //Just increment the counter } } echo "</tr></table>"; mysql_free_result($result); HTH -Brad


« previous php.db (#21608) next »