CameronDane
05-03-2009, 09:05 AM
I am trying to print the column names and rows so that the rows can be update via the web and the user knows which columns are being updated. however I would like to print the column names dynamically as they will be changing frequently and I do not want to have to go and update the html in the page when they do change.
Thanks,
C.D.
I got it....
Here is the code to do it!
<?
mysql_connect("localhost", "mortgak3_admin","chanchu4");
mysql_select_db( "mortgak3_marketing" );
print "Executing SQL...< br />";
$result_set = mysql_query( "SELECT * FROM social_mkt WHERE article_id = '1'");
print "<table>";
//print the headers
for( $c=0; $c<mysql_num_fields( $result_set ); $c++ ) {
print "<th>". mysql_field_name( $result_set, $c ) . "</th>";
}
//print all the rows
while( $record = mysql_fetch_row( $result_set ) ) {
print "<tr>";
for( $c=0; $c<mysql_num_fields( $result_set ); $c++) {
print "<td>" . $record[$c] . "</td>";
}
print "</tr>";
}
print "</table>";
?>
Thanks,
C.D.
I got it....
Here is the code to do it!
<?
mysql_connect("localhost", "mortgak3_admin","chanchu4");
mysql_select_db( "mortgak3_marketing" );
print "Executing SQL...< br />";
$result_set = mysql_query( "SELECT * FROM social_mkt WHERE article_id = '1'");
print "<table>";
//print the headers
for( $c=0; $c<mysql_num_fields( $result_set ); $c++ ) {
print "<th>". mysql_field_name( $result_set, $c ) . "</th>";
}
//print all the rows
while( $record = mysql_fetch_row( $result_set ) ) {
print "<tr>";
for( $c=0; $c<mysql_num_fields( $result_set ); $c++) {
print "<td>" . $record[$c] . "</td>";
}
print "</tr>";
}
print "</table>";
?>