Example #1
0
$dbName = strtoupper(get_current_user()) . '_UVM_Courses';
$thisDatabase = new myDatabase($dbUserName, $whichPass, $dbName);
/* ##### html setup */
$phpSelf = htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES, "UTF-8");
$path_parts = pathinfo($phpSelf);
print '<body id="' . $path_parts['filename'] . '">';
/* ##### Step two 
 * 
 * open the file that contains the query
 */
$myfile = fopen("q06.sql", "r") or die("Unable to open file!");
$query = fread($myfile, filesize("q06.sql"));
/* ##### Step three
 * Execute the query
 *      */
$results = $thisDatabase->select($query);
/* ##### Step four
 * prepare output and loop through array
 *      */
$numberRecords = count($results);
print "<h2>Total Records: " . $numberRecords . "</h2>";
print "<h3>SQL: " . $query . "</h3>";
print "<table>";
$firstTime = true;
/* since it is associative array display the field names */
foreach ($results as $row) {
    if ($firstTime) {
        print "<thead><tr>";
        $keys = array_keys($row);
        foreach ($keys as $key) {
            if (!is_int($key)) {
Example #2
0
$thisDatabase = new myDatabase($dbUserName, $whichPass, $dbName);
// -- Table structure for table `tblSections`
$query = "DROP TABLE IF EXISTS tblEnrolls";
$results = $thisDatabase->delete($query);
$query = "CREATE TABLE IF NOT EXISTS tblEnrolls ( ";
$query .= "fnkCourseId int(11) NOT NULL, ";
$query .= "fnkSectionId int(11) NOT NULL, ";
$query .= "fnkStudentId int(11) NOT NULL, ";
$query .= "fldGrade int(11) NOT NULL, ";
$query .= "PRIMARY KEY (`fnkCourseId`,`fnkSectionId`,`fnkStudentId`)";
$query .= ") ENGINE=InnoDB DEFAULT CHARSET=utf8";
$results = $thisDatabase->insert($query);
print "<p>tblEnrolls Created.</p>";
//get all the student id numbers
$query = "SELECT pmkStudentId, 0 as numClasses FROM tblStudents";
$allStudents = $thisDatabase->select($query);
//get all the cs classes sections id numbers
$query = "SELECT fnkCourseId, fldCRN, fldNumStudents ";
$query .= "FROM tblSections, tblCourses ";
$query .= "WHERE pmkCourseId=fnkCourseId ";
$query .= "AND fldDepartment = 'CS'";
//get all the sections id numbers
//$query = "SELECT fnkCourseId, fldCRN, fldNumStudents ";
//$query .= "FROM tblSections";
$allSections = $thisDatabase->select($query);
if ($debug) {
    print "<p>allSections:<pre>";
    print_r($allSections);
    print "</pre></p>";
}
//@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Example #3
0
 $query .= "  fldType as Type ,";
 $query .= "  fldStart as Start ,";
 $query .= "  fldStop as Stop ,";
 $query .= "  fldDays as Days ,";
 $query .= "  fldBuilding as Building ,";
 $query .= "   fldRoom as Room ";
 $query .= "FROM tblCourses , tblSections , tblTeachers";
 $query .= ' WHERE pmkCourseID = fnkCourseID';
 $query .= ' AND pmkNetID = fnkTeacherNetID';
 $query .= ' AND fldStart like "' . $Start . '%"';
 $query .= ' AND fldBuilding like "' . $Building . '%"';
 $query .= ' AND fldDepartment like "%' . $Department . '%"';
 $query .= ' AND fldCourseNumber like "%' . $CourseNumber . '%"';
 $query .= ' AND fldLastName like "%' . $LastName . '%"';
 $data = array($Start, $Building, $Department, $CourseNumber, $LastName);
 $results = $thisDatabase->select($query, $data);
 /////////// CALC COUNT AND DISPLAY ////////////
 $numberRecords = count($results);
 print "<h2>Total Records: " . $numberRecords . "</h2>";
 $keys = array_keys($row);
 //////////
 //////// TABLE CONSTRUCTION ///////////////
 print "<table>";
 $firstTime = true;
 /* since it is associative array display the field names */
 foreach ($results as $row) {
     if ($firstTime) {
         print "<thead><tr>";
         $keys = array_keys($row);
         foreach ($keys as $key) {
             preg_replace(' /(?<! )(?<!^)(?<![A-Z])[A-Z]/', ' $0', substr($key, 3));
Example #4
0
$thisDatabase = new myDatabase($dbUserName, $whichPass, $dbName);
$phpSelf = htmlentities($_SERVER['PHP_SELF'], ENT_QUOTES, "UTF-8");
$path_parts = pathinfo($phpSelf);
print '<body id="' . $path_parts['filename'] . '">';
$tableName = "";
if (isset($_GET['getRecordsFor'])) {
    // Sanitize the input to help prevent sql injection
    $tableName = htmlentities($_GET['getRecordsFor'], ENT_QUOTES);
}
print "<h2>Database: " . $dbName . "</h2>";
// print out a list of all the tables and their description
// make each table name a link to display the record
print "<section id='tables2'>";
print "<table>";
$query = "SHOW TABLES";
$results = $thisDatabase->select($query);
foreach ($results as $row) {
    // table name link
    print '<tr class="odd">';
    echo "<th colspan='6' style='text-align: left'><a href='?getRecordsFor=" . $row[0] . "#" . $row[0] . "'>" . $row[0] . "</a></th></tr>";
    //get the fields and any information about them
    $query = "SHOW COLUMNS FROM " . $row[0];
    $results2 = $thisDatabase->select($query);
    foreach ($results2 as $row2) {
        print "<tr>";
        print "<td>" . $row2['Field'] . "</td>";
        print "<td>" . $row2['Type'] . "</td>";
        print "<td>" . $row2['Null'] . "</td>";
        print "<td>" . $row2['Key'] . "</td>";
        print "<td>" . $row2['Default'] . "</td>";
        print "<td>" . $row2['Extra'] . "</td>";