Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function SQLResultTable($Query)
- {
- $host = "localhost";
- $user = "root";
- $pass = "";
- $db = "Quality_Monitoring";
- $link = mysql_connect($host, $user, $pass) or die('Could not connect: ' . mysql_error()); //build MySQL Link
- mysql_select_db($db) or die('Could not select database'); //select database
- $Table = ""; //initialize table variable
- $Table.= "<table id='Table1' border='1' style="border-collapse: collapse; text-align: center; font-size: 10px; cellspacing: 5px; ">"; //Open HTML Table
- $Result = mysql_query($Query); //Execute the query
- if(mysql_error())
- {
- $Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
- }
- else
- {
- //Header Row with Field Names
- $NumFields = mysql_num_fields($Result);
- $Table.= "<tr style="background-color: #000066; text-align: center; color: #FFFFFF;">";
- for ($i=0; $i < $NumFields; $i++)
- {
- $Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
- }
- $Table.= "</tr>";
- //Loop thru results
- $RowCt = 0; //Row Counter
- while($Row = mysql_fetch_assoc($Result))
- {
- //Alternate colors for rows
- if($RowCt++ % 2 == 0) $Style = "background-color: #CCCCCC;";
- else $Style = "background-color: #FFFFFF;";
- $Table.= "<tr style="$Style">";
- //Loop thru each field
- foreach($Row as $field => $value)
- {
- $Table.= "<td>$value</td>";
- }
- $Table.= "</tr>";
- }
- // $Table.= "<tr style="background-color: #000066; color: #FFFFFF;"><td colspan='$NumFields'>Query Returned " . mysql_num_rows($Result) . " records</td></tr>";
- }
- $Table.= "</table>";
- return $Table;
- }
- //Header Row with Field Names
- $NumFields = mysql_num_fields($Result);
- $Table.= "<tr style="background-color: #000066; text-align: center; color: #FFFFFF;">";
- for ($i=0; $i < $NumFields; $i++)
- {
- $Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
- }
- $Table.= "</tr>";
- function SQLResultTable($Query)
- {
- $host = "localhost";
- $user = "root";
- $pass = "";
- $db = "Quality_Monitoring";
- $link = mysql_connect($host, $user, $pass) or die('Could not connect: ' . mysql_error()); //build MySQL Link
- mysql_select_db($db) or die('Could not select database'); //select database
- $Table = ""; //initialize table variable
- $Table.= "<table id='Table1' border='1' style="border-collapse: collapse; text-align: center; font-size: 10px; cellspacing: 5px; ">"; //Open HTML Table
- $Result = mysql_query($Query); //Execute the query
- if(mysql_error())
- {
- $Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
- }
- else
- {
- //Loop thru results
- $RowCt = 0; //Row Counter
- while($Row = mysql_fetch_assoc($Result))
- {
- //Alternate colors for rows
- if($RowCt++ % 2 == 0) $Style = "background-color: #CCCCCC;";
- else $Style = "background-color: #FFFFFF;";
- $Table.= "<tr style="$Style">";
- //Loop thru each field
- foreach($Row as $field => $value)
- {
- $Table.= "<td>$value</td>";
- }
- $Table.= "</tr>";
- }
- // $Table.= "<tr style="background-color: #000066; color: #FFFFFF;"><td colspan='$NumFields'>Query Returned " . mysql_num_rows($Result) . " records</td></tr>";
- }
- $Table.= "</table>";
- return $Table;
- }
- function SQLResultTable($Query)
- {
- $host = "localhost";
- $user = "root";
- $pass = "";
- $db = "Quality_Monitoring";
- $link = mysql_connect($host, $user, $pass) or die('Could not connect: ' . mysql_error()); //build MySQL Link
- mysql_select_db($db) or die('Could not select database'); //select database
- $Table = ""; //initialize table variable
- $Table.= "<table id='Table1' border='1' style="border-collapse: collapse; text-align: center; font-size: 10px; cellspacing: 5px; ">"; //Open HTML Table
- $Result = mysql_query($Query); //Execute the query
- if(mysql_error())
- {
- $Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
- }
- else
- {
- //Header Row with Field Names
- $NumFields = mysql_num_fields($Result);
- $Table.= "<tr style="background-color: #000066; text-align: center; color: #FFFFFF;">";
- for ($i=0; $i < $NumFields; $i++)
- {
- $Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
- }
- $Table.= "</tr>";
- //Loop thru results
- $RowCt = 0; //Row Counter
- while($Row = mysql_fetch_assoc($Result))
- {
- //Alternate colors for rows
- if($RowCt!=0)
- {
- if($RowCt % 2 == 0) $Style = "background-color: #CCCCCC;";
- else $Style = "background-color: #FFFFFF;";
- $Table.= "<tr style="$Style">";
- //Loop thru each field
- foreach($Row as $field => $value)
- {
- $Table.= "<td>$value</td>";
- }
- $Table.= "</tr>";
- }
- $RowCt++;
- }
- // $Table.= "<tr style="background-color: #000066; color: #FFFFFF;"><td colspan='$NumFields'>Query Returned " . mysql_num_rows($Result) . " records</td></tr>";
- }
- $Table.= "</table>";
- return $Table;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement