Database Connection Failure!"; } else // If the database connects successfully continue { if (isset($_GET['projectName'])) // Checks to see if the GET variable is set { // Sanitizes input and intializes the GET variable $tableName = mysql_real_escape_string($_GET['projectName']); $resultGetReport= mysql_query("SELECT * FROM `$tableName`"); if (!$resultGetReport) // if the project does not exist print an error { echo "

Project Does Not Exist

"; } else // Prints the entire table in neat HTML format { echo "

View Project Report

"; echo "

$tableName

"; if (mysql_num_rows($resultGetReport) > 0) // Checks to see if there is at least one row { $queryCountRows = "SELECT COUNT(*) FROM `$tableName`"; $resultCountRows = mysql_query($queryCountRows); $numUsers = mysql_fetch_array($resultCountRows); echo "

Number of Vistors: " . $numUsers[0] . "

"; echo "\n"; echo "\n"; $numFields = mysql_num_fields($resultGetReport); // Obtains the number of fields to priont for($i=0; $i<$numFields; $i++) // Loops through printing all of the headers { $field = mysql_fetch_field($resultGetReport); echo "\n"; // Upper cases the first letter of each word in the header name } echo "\n"; $rowColorNum = 1; // printing table rows while($row = mysql_fetch_row($resultGetReport)) { if ( ($rowColorNum % 2) == 0 ) // Alternates row colors { $rowColor = 'even'; } else { $rowColor = 'odd'; } echo "\n\n"; // prints each cell in the row foreach($row as $cell) { echo "\n"; } echo "\n"; $rowColorNum++ ; } echo "\n
" . ucwords($field->name) . "
$cell
"; } else // If there aren't any rows it prints empty table { echo "

The Table is empty!

"; } } } else // If the projectName get variable is not passed through { echo "

Invalid Parameters Passed to Page.

"; } // mysql_close(); // Closes all open DB connections } ?>