Server IP : 172.16.15.8 / Your IP : 18.117.71.213 Web Server : Apache System : Linux zeus.vwu.edu 4.18.0-553.27.1.el8_10.x86_64 #1 SMP Wed Nov 6 14:29:02 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.2.24 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/cngray/www/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php session_start(); if(!isset($_SESSION['username'])){ header("location:BBWelcome.php"); } else { ?> <html> <center> <?php $username = $_SESSION['username']; $pass = $_SESSION['pass']; $check = $_SESSION['check']; $_SESSION['username'] = $username; $_SESSION['pass'] = $pass; $_SESSION['check'] = 2; $host = 'localhost'; $user = 'cngray'; $passwd = 'vwccscngray'; $database = 'cngray'; $connect = mysql_connect($host, $user, $passwd); mysql_select_db($database); $query = "select * from BBUsers"; $Result_id = mysql_query($query, $connect); if($Result_id) { $Fname = mysql_result(mysql_query("select FName from BBUsers where Username like '$username'"), 0); $Lname = mysql_result(mysql_query("select LName from BBUsers where Username like '$username'"), 0); $PorS = mysql_result(mysql_query("select Year from BBUsers where Username like '$username'"), 0); if($PorS > 0) { $FL = $Fname[0]; $USERNAME = $FL.$Lname;; $USERNAME = strtolower($USERNAME); $query = "select * from $USERNAME"; $Result_id = mysql_query($query, $connect)or die(mysql_error()); if($Result_id) { print "<font size = 10> Courses </font><br>"; print "<hr><hr>"; print "<br><font size = 5>"; print "Current Courses:<br>"; print '<table border = 1>'; print "<th> Class <th> Assignment <th> Grade "; while($row = mysql_fetch_row($Result_id)) { print '<tr>'; foreach($row as $field) print "<td> $field </td> "; print '</tr>'; } print '<table border = 0>'; $SCourse = "select Course from Courses"; $SResult = mysql_query($SCourse, $connect) or die(mysql_error()); $CArray = array(); $i = 0; while($row = mysql_fetch_row($SResult)) { foreach($row as $field) { $CArray[$i] = $field; $i++; } } $WholeName = $Fname.' '.$Lname; $Grades = array(); $Array1 = array(); $Array1Count = 0; for($x = 0; $x < count($CArray); $x++) { $class =str_replace(' ', '', $CArray[$x]); $CourseQuery = "select count(Student) from $class where Student = '$WholeName'"; $CourseResult = mysql_query($CourseQuery, $connect) or die(mysql_error()); $CourseRow = mysql_fetch_row($CourseResult); if($CourseRow[0] >= 1) { $Array1[$Array1Count] = $class; $Array1Count++; } } print "<br><br>Have Courses for Student<br>"; print_r($Array1); $FGrade = array(); $ArrCourse = array(); $GradeArray = array(); for($x = 0; $x < count($Array1); $x++) { $class =str_replace(' ', '', $Array1[$x]); $GradeQuery = "select Grade from $USERNAME where Class = '$class'"; print "$GradeQuery<br>"; $GradeResult = mysql_query($GradeQuery, $connect) or die(mysql_error()); $GradeRows = mysql_fetch_row($GradeResult); $GradeCount = 0; $FGrade[$x] = 0; $ArrCourse[$x] = $class; if($GradeRows >= 1) { while($row = mysql_fetch_row($GradeResult)) { foreach($row as $field) { print "<br>$field<br>"; $GradeArray[$GradeCount] = $field; $GradeCount++; } } print_r($GradeArray); for($y = 0; $y < count($GradeArray); $y++) $FGrade[$x] += $GradeArray[$y]; } $GradeArray = array(); } print_r($FGrade); print_r($ArrCourse); print "<br><br>Have Grades for Student<br>"; print "Course Total Grade:<br>"; print '<table border = 1>'; print "<th> Course <th> Grade "; for($x = 0; $x < count($ArrCourse); $x++) { print '<tr>'; print "<td> $ArrCourse[$x] </td> "; print "<td> $FGrade[$x] </td>"; print '</tr>'; } print '<table border = 0>'; } else print "Fail to output courses for student\n\n"; } elseif($Pors == 0) { $Lquery = "select LName from BBUsers where Username like '$username'"; $LN = mysql_result(mysql_query("select LName from BBUsers where Username like '$username'"), 0); $Result_id = mysql_query($Lquery, $connect); if($Result_id) { $Cquery = "select Course from Courses where Prof like '$LN'"; $CResult_id = mysql_query($Cquery,$connect); if($CResult_id) { $Course_Array = array(); $i = 0; while($row = mysql_fetch_row($CResult_id)) foreach($row as $field) { $Course_Array[$i] = $field; $i++; } Print "Current Courses:<br>"; for($x = 0; $x < sizeof($Course_Array); $x++) { $class = $Course_Array[$x]; $class = str_replace(' ','', $class); $query = "select Student from $class"; $Result_id = mysql_query($query, $connect); $numrows = mysql_num_rows($Result_id);?> <form action = "BBAA.php" method = post><?php if($Result_id) { ?> <?php print "Course: $Course_Array[$x]\n"; if($numrows == 0) { print "<br>No Students in $class<br>"; } else { print '<table border = 1>'; print "<th> Students "; while($row = mysql_fetch_row($Result_id)) { print '<tr>'; foreach($row as $field) print "<td> $field </td> "; print '</tr>'; } print '<table border = 0>'; } $_SESSION['class'] = $Course_Array[$x]; $_SESSION['pro'] = $LN; print "<br><br>"; } else print "Fail to get Students in class<br><br>"; } ?> <select name = course> <?php for($q = 0; $q < count($Course_Array); $q++) print "<option> $Course_Array[$q] </option>"; ?> </select> <br><input type = submit value = "Add/Remove Students" name = "ar"> <INPUT Type=submit VALUE="Assignments" name = "ass"> <?php } else print "Fail to get Courses\n\n"; } else print "Fail to get Professor information\n\n"; } print "\n\n";?> <br><br><INPUT Type=button VALUE='Back' onClick = 'location.href = "BBMain.php"'> <?php } else print "Fail to get user data\n\n"; } mysql_close($connect); ?>