Notice that you are adding $x in the loop. You are getting a row, printing
out index 0 of table_headers, incrementing $x, then moving to the next row.
Basically you are fetching row 1 column 1, row 2 column 2, row 3 column 3,
etc. instead of fetching all rows.
Do this instead:
$query = "SELECT * FROM " .$table. "" ;
$result = mysql_query ( $query ) or die( mysql_error () );
while ( $row = mysql_fetch_assoc ($result)) {
while(list(,$col)=each($row)) {
echo "<TD>{$col}</TD>";
}
}
This will echo all rows, and for each row will echo all values in order of
your table, which is also the order of $table_headers.
Peter
On Sun, 10 Nov 2002, David Rice wrote:
> <?
> /* Select all the records from the table */
> $query = "SELECT * FROM " .$table. "" ;
> $result = mysql_query ( $query ) or die( mysql_error () );
> $x = 0 ;
> while ( $row = mysql_fetch_assoc ($result)) {
> ?>
> <TD>
> <?
> echo $row[$table_headers[$x]] ;
> ?>
> </TD>
> <?
> $x++ ;
> }
> ?>
> </TABLE>
---------------------------------------------------------------------------
Peter Beckman Systems Engineer, Fairfax Cable Access Corporation
[EMAIL PROTECTED] http://www.purplecow.com/
---------------------------------------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php