Re: Newbie question about filling tables.

From: Date: Wed, 22 Nov 2000 20:32:21 +0000
Subject: Re: Newbie question about filling tables.
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26718@lists.php.net to get a copy of this message
Hello Angel, (ABR == "Angel Behar Rodriguez") abehar@mail.pacificnet.com.mx writes: ABR> Hi, Im running php 4.0.3pl1 in a linux 6.2 box, and I'm trying to "fill" a ABR> two column x five row table with a different record each cell, I don't ABR> have too much experience with php programming, so I can make the MySql ABR> query and fetch the results, but once I start the ABR> while($i=mysql_fetch_array($query)) command then ABR> I dont' know how to display each record in the cell, hope somebody can ABR> help me or give me some ideas. <table border="0" cellpadding="3" cellspacing="0"> <?php while($row = @mysql_fetch_array($query, $connection)) { print '<tr>'; print "<td>$row['column_one']</td><td>$row['column_two']</td>"; print '</tr>'; } ?> </table> Replace column_one and column_two with your actual column names. If you want more columns in a single HTML table cell, just use: print "<td>$row['column_one'] $row['column_two']</td> print "<td>$row['column_three'] $row['column_four']</td>"; Does that work? :-) mysql_fetch_object() is easier, IMO, for what you're doing. -Brian

« previous php.general (#26718) next »