All pastes #162908 Raw Edit

Miscellany

public php v1 · immutable
·published 2006-09-06 23:54 UTC
rendered paste body
<style> td.green { background-color:#c7eca9; } td.white { background-color:#fff; } </style><?php//Connect to mysql.include ('connection_db.php');//This is the table to fetch from.$table = 'ATM';//Will be used to sort the rows.$id= 'Server_Name';//Perform a query for rows and to populate$f_names = mysql_query("SHOW COLUMNS FROM $table ");//create Begining of Html.echo "<html>\n";echo "<head>\n<head>\n\n";echo "<body>\n";echo "<table border=1>\n";echo "<tr>\n"; $cols = array();//Fetch Query Results and Spit out Row Nameswhile ($row_n= mysql_fetch_assoc($f_names)){        $cols[] = $row_n['Field'];	echo '<th>'. $row_n['Field'] ."</th>\n";}$result = mysql_query("SELECT * FROM $table ORDER BY $id");while($row = mysql_fetch_assoc($result)){   echo '<tr>';   foreach ( $cols as $fieldname ) {	echo '<td>'. $row[$fieldname] ."</td>\n";   }   echo '</tr>';}?>