I'm trying to get ranked for a certain student out of a class of one hundred, I want to be able Display the rank of students.
I am trying to get a grade from grade and grade points. For example if there are 2A + grades with 10 digits in the student1
and student 2
have 3b grades, then with the total 10 digits Student 1
will rank high I was wondering how can I do this PHP & amp; Amp; MySQL?
Here PHP & amp; MySQL code is still to me.
$ gp = array (); Include homework_grades on grade except $ Dbc = mysqli_query ($ mysqli, "Selection Grade. *, Homework_grade. *, Users_homework. * Grade. Id = homework_grades.grade_id LEFT JOIN users_homework at homework_grades.users_homework_id = users_homeework.id WHERE users_homework.user_id = '$ User_id' and users_homework.grad_average = 'A +' "); If (! $ Dbc) {print mysqli_error ($ mysqli); } And {while ($ line = mysqli_fetch_array ($ dbc)) {$ gp [] = $ line ['grade_point']; }} Echo array_sum ($ gp);
This is my MySQL table.
Make Table Homvrk_gred (ID INT Anlikit No Altraangrement No, Gred_aid INT Ansated, users_homework_id INT Anaked tap, User_id INT unaware tap, PRIMARY KEY (id)); Table Create grades (ID INT is not unknown, Altraangrement, Akshr_graf VARCHAR is not zero, Gred_point Float unknown, zero, 0, PRIMARY KEY (id)); Create Table users_homework (id INT Unlimited Attonggrement, Ughr_aidi INT Ansonded tap Homvrk_saint Langvent not tap Gred_avrej VARCHAR (ID) default NULL, primary);
renewed
you need Overall, a SUM () and COUNT () COUNT will tell you the number of jobs, the amount will tell you the total grade points by the user_id for each student to get this group.
$ gp = array (); Include homework_gread in grading from grade left as num_assignments as $ Dbc = mysqli_query ($ mysqli, "SELECT SUM (grade_points) grade_points, user_id, count (*) grade.id = homework_grades.grade_id LEFT JOIN users_homework at homework_grades users_homework_id = users_homework.id group by Gred_point Diissi, Anaisiaansiament ASC 'by Upyogkrta_aidi); if (! $ Dbc) {print mysqli_error ($ mysqli);} and {$ i = 1; while ($ row = mysqli_fetch_array ($ dbc) ) {$ User [$ row ['user_id']] = $ i ++; $ rank [] = $ line ['user_id']; $ GP [] = $ Row [ 'Gred_point'];}} // User rank rank 10 "echo User_id 10 {The $ user [10]}"; echo "in the ranks of all users:"; print_r ($ rank);
This grade will add points, and calculate the number of assignments. Sorting will ensure that 10 students with 3 assignments, compared to a student with 10 marks of 4 assignments. Rank higher.
View aggregates by COUNT SUM and GROUP.
Comments
Post a Comment