retrieving data from mysql table

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



okay thank's for the help on my previous question. I've got it to retrieve a 
list of column headers now, i want it to retrieve all the records from the 
table and print them underneath.

the code i have is

**********************************************************************

<?

/* get a list of the column headers from the table */

	mysql_select_db("filterseveuk") or die(mysql_error());

	$query = "SHOW COLUMNS FROM " .$table. "";

	$result =  mysql_query ( $query ) or die( mysql_error () );

?>
	<TABLE border=1><TR>
<?
	$x = 0 ;
	while ($row = mysql_fetch_assoc ($result)){

?>
	<TD>
<?

/* before printing the table header, we put it in the array "table_headers" 
*/

	$table_headers[$x] = $row['Field'] ;
	echo $row['Field'];
	$x++ ;
?>
	</TD>
<?
	}
?>
	</TR>
	<TR>
<?

/* 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>

**********************************************************************

this outputs

**********************************************************************

http://www.filterseven.co.uk/admin/index.php?table=user&action=edit

any ideas?

 



_________________________________________________________________
STOP MORE SPAM with the new MSN 8 and get 2 months FREE* 
http://join.msn.com/?page=features/junkmail


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux