
sule
Members-
Posts
21 -
Joined
-
Last visited
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
sule's Achievements

Member (2/5)
0
Reputation
-
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
You don't understand the structure of my code that is why. But i take all your submissions and Thanks The submit is a request coming from a form in another page. -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Thank you Mr. Barand my code is now working but want to add comments to every student so that the form master can comment about student's conduct attitude and interest fot parent to monitor students progress. The print out should also be one student per page <?php include 'session.php'; ?> <?php include '../db/dbconnect.php'; define("HOST", 'localhost'); define("USERNAME", 'root'); define("PASSWORD", ''); define("DATABASE", 'sms'); ?> <!doctype html> <html lang="en"> <head> <!-- Required meta tags --> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <link rel="stylesheet" href="../css/bootstrap.min.css" /> <link rel="stylesheet" href="../bootstrap-icons/font/bootstrap-icons.min.css"> <link rel="stylesheet" href="../bootstrap-icons/font/bootstrap-icons.min.css"> <link rel="stylesheet" type="text/css" href="../css/viewpasscodeadmin.css" /> <link rel="stylesheet" href="../css/report1.css"> <link rel="stylesheet" href="../font/stylesheet.css"> <link rel="stylesheet" href="../css/dataTables.bootstrap5.css" /> <link rel="stylesheet" href="../css/buttons.bootstrap5.css" /> <link rel="stylesheet" href="../css/responsive.bootstrap5.css" /> <link rel="stylesheet" href="../font/stylesheet.css"> <title>report</title> </head> <body> <div class="container"> <?php //error_reporting(0); ?> <?php if (isset($_POST['submit'])) { $acayear = mysqli_real_escape_string($con, $_POST['acayear']); $semester = mysqli_real_escape_string($con, $_POST['semester']); $form = mysqli_real_escape_string($con, $_POST['form']); $class = mysqli_real_escape_string($con, $_POST['class']); } function pdoConnect($dbname = DATABASE) { $db = new PDO("mysql:host=" . HOST . ";dbname=$dbname;charset=utf8", USERNAME, PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db->setAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE, true); return $db; } $pdo = pdoConnect(); $res = $pdo->query("SELECT school.school, school.logo, student.gender, student.program, student.house, student.image, marks.acayear, marks.semester, marks.form ,marks.class, marks.studentid, marks.name, marks.subject, marks.class_score1, marks.exam_score1,marks.total, marks.grade, marks.remarks, RANK() OVER (PARTITION BY marks.acayear, marks.semester, marks.lessonsid ORDER BY marks.total DESC) as rank FROM marks LEFT JOIN student ON marks.studentid=student.studentid LEFT JOIN school ON student.schoolid=school.schoolid WHERE marks.acayear='{$acayear}' AND marks.semester='{$semester}' AND marks.form='{$form}' AND marks.class='{$class}' ORDER BY name, subject"); $previd = 0; $tdata = ''; foreach ($res as $r) { if ($r['studentid'] != $previd) { if ($previd != 0) { // if not the first $tdata .= "\n</table>\n</div>\n</div>\n\n"; // close preceding report } $tdata .= outputReportHeading(...array_slice($r, 0, 12)); $previd = $r['studentid']; } $tdata .= outputSubject(...array_slice($r, 7)); // close last report } $tdata .= "\n</table>\n</div>\n</div>\n\n"; # # FUNCTIONS # function outputReportHeading($school, $logo, $gender, $program, $house, $image, $acayear, $semester, $form, $class, $studentid, $name) { return <<<HEAD <div class="logo1"> <img src="../uploads/student/$image" width="100px" class="rounded float-end mt-3"> </div> <div class="logo"> <img src="../uploads/logo/$logo" width="100px" class="rounded float-start mt-3"> </div> <div class="heading mt-2"> $school </div> <div class="heading2"><b> $acayear ACADEMIC YEAR</b> </div> <div class='heading2'> <b>Student ID:</b> <span class=''>$studentid</span> <b>Name of Student:</b> <span class=''>$name</span> <br> <b>Semester:</b> <span'>$semester</span> <b>House:</b> <span>$house</span> <b>Gender:</b> <span>$gender</span> <b>Program:</b> <span>$program</span> <b>Class:</b> <span>$form $class</span> </div> <div class="heading"> STUDENT TERMINAL REPORT </div> <div class="tablewrap mt-2"> <table class="table table-bordered table-sm" cellspacing="0" width="100%"> <thead> <tr class="text-center"> <th class="th-sm text-left">Subject</th> <th class="th-sm text-center">Class Score</th> <th class="th-sm text-center">Exam Score</th> <th class="th-sm text-center" >Total</th> <th class="th-sm text-center">Grade</th> <th class="th-sm text-center" >Pos</th> <th class="th-sm text-center" >Remarks</th> </tr> <thead> HEAD; } function outputSubject($semester, $form, $class, $studentid, $name, $subject, $class_score1, $exam_score1, $total, $grade, $remarks, $rank) { return <<<SUB <tbody> <tr> <td class="text-left" >$subject</td> <td class="text-center">$class_score1</td> <td class="text-center">$exam_score1</td> <td class="text-center">$total</td> <td class="text-center">$grade</td> <td class="text-center">$rank</td> <td class="text-left">$remarks</td> </tr> </div> </tbody> SUB; } ?> <?= $tdata; ?> </div>. </body> </html> -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
database.txt -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Please i tried to modified my table with some related tables joins so that i can have the results dynamic but the my table is not appearing again. Please i need your help. How can i contact you privately? SELECT school.school, school.logo, student.gender, student.program, student.house, student.enstatus, student.image, marks.acayear, marks.semester, marks.form ,marks.class, marks.studentid, marks.name, marks.subject, marks.class_score1, marks.exam_score1,marks.total, marks.grade, marks.remarks, RANK() OVER (PARTITION BY marks.acayear, marks.semester, marks.lessonsid ORDER BY marks.total DESC) as rank FROM marks LEFT JOIN student ON marks.studentid=student.studentid LEFT JOIN school ON student.schoolid=school.schoolid WHERE marks.acayear='2024/2025' AND marks.semester='1' AND marks.form='3' AND marks.class='SCI A' ORDER BY name, subject -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Please i saw your code but i am not able to use it because you used PDO instead of MySQLI. can you code it in mysqli for me to see if i can use it. Thank you. <?php define("HOST", 'localhost'); define("USERNAME", '????'); define("PASSWORD", '????'); define("DATABASE", '????'); // default database name function pdoConnect($dbname=DATABASE) { $db = new PDO("mysql:host=".HOST.";dbname=$dbname;charset=utf8",USERNAME,PASSWORD); $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $db->setAttribute(PDO::MYSQL_ATTR_LOCAL_INFILE, true); return $db; } $pdo = pdoConnect(); $res = $pdo->query("SELECT marks.acayear , marks.semester , marks.form , marks.class , marks.studentid , marks.name , marks.subject , marks.class_score1 , marks.exam_score1 , ROUND(marks.total, 1) as total , marks.grade , marks.remarks , RANK() OVER (PARTITION BY marks.acayear, marks.semester, marks.lessonsid ORDER BY marks.total DESC) as rank FROM marks WHERE marks.acayear='2024/2025' AND marks.semester='1' AND marks.form='3' AND marks.class='SCI A' ORDER BY name, subject; "); $previd = 0; $tdata = ''; foreach ($res as $r) { if ($r['studentid'] != $previd) { if ($previd != 0) { // if not the first $tdata .= "\n</table>\n</div>\n</div>\n\n"; // close preceding report } $tdata .= outputReportHeading(...array_slice($r, 0, 6)); $previd = $r['studentid']; } $tdata .= outputSubject(...array_slice($r, 6)); // close last report } $tdata .= "\n</table>\n</div>\n</div>\n\n"; # # FUNCTIONS # function outputReportHeading($acayear, $semester, $form, $class, $studentid, $name) { return <<<HEAD <div class='report w3-container w3-white'> <div class='report-head'> SAVELUGU SENIOR HIGH SCHOOL </div> <div class='report-head'> $acayear ACADEMIC YEAR </div> <div class='w3-row w3-margin-top'> <div class='w3-col m1 w3-center'> [SCHOOL<br>CREST] </div> <div class='w3-col m5 report-subhead'> Student ID: <span class='hval'>$studentid</span> <br> Name: <span class='hval'>$name</span> <br> Semester: <span class='hval'>$semester</span> </div> <div class='w3-col m5 report-subhead'> House: <span class='hval'></span> <br> Gender: <span class='hval'></span> <br> Class: <span class='hval'>$form $class</span> </div> <div class='w3-col m1 w3-center'> [PHOTO] </div> </div> <div class='report-head w3-margin-top'> STUDENT TERMINAL REPORT </div> <div class='w3-responsive'> <table border='1' class='scores'> <tr> <th>Subject</th> <th class='w3-hide-small'>Class Score</th> <th class='w3-hide-small'>Exam Score</th> <th>Total</th> <th>Grade</th> <th>Pos</th> <th>Remarks</th> </tr> HEAD; } function outputSubject($subject, $class_score1, $exam_score1, $total, $grade, $remarks, $rank) { return <<<SUB <tr> <td>$subject</td> <td class='w3-hide-small ca'>$class_score1</td> <td class='w3-hide-small ca'>$exam_score1</td> <td class='ca'>$total</td> <td class='ca'>$grade</td> <td class='ca'>$rank</td> <td>$remarks</td> </tr> SUB; } ?> <!DOCTYPE html> <html lang="en"> <head> <title>Example Reports 1</title> <meta charset="utf-8"> <link rel="stylesheet" href="https://www.w3schools.com/w3css/4/w3.css"> <style type='text/css'> body { background-color: #FCF8E8; } .report { margin: 16px; padding: 8px; border: 1px solid gray; } .report-head { font-size: 18pt; font-weight: 600; text-align: center; } .report-subhead { font-size: 14pt; font-weight: 300; } .hval { font-weight: 600; color: blue; } .scores { width: 100%; border-collapse: collapse; } th { padding: 8px 2px; background-color: gray; color: white; } td { padding: 8px 4px; } .ca { text-align: center; } </style> </head> <body> <?= $tdata ?> </body> </html> -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Woow!!!, the world is full of knowledgeable people. Mr. Barand, how can i learn this coding you have done? I will be grateful if you can support me as the saying goes ''It is better teaching how to fish than giving me fish". Words alone cannot express my happiness. I am so much grateful you. Than you. -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Thank you for assistance. I am still a newbie who is learning php mysql myself without any mentor. It is my passion of using the web to solve problems at my work place. After my first degree in information technology i wanted to help my people use the web at local level to solve their problems. I am grateful for your response and advice given me. By the way I am from Ghana -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
The table head is not one because each student have a table which need to be looped. I can't just figure out why the first row data appears ones without its tables -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
Mr Baran I salute you: I am almost done with the help you offered me. I am left with something small. My first record displayed without the data but on heading, the rest of the data is perfect. see my code $select = "SELECT school.school, school.logo, student.gender, student.program, student.house, student.enstatus, student.image, marks.studentid, marks.name, marks.acayear, marks.semester, marks.form, marks.class, marks.subject, marks.class_score1, marks.exam_score1, marks.total, marks.grade, marks.remarks, RANK() OVER (PARTITION BY marks.lessonsid, marks.acayear, marks.form, marks.semester, marks.subject, marks.class ORDER BY marks.total DESC) as rank FROM marks LEFT JOIN student ON marks.studentid=student.studentid LEFT JOIN school ON student.schoolid=school.schoolid WHERE marks.acayear='2024/2025' AND marks.semester='1' AND marks.form='3' AND marks.class='SCI A' ORDER BY marks.name, marks.subject"; $run = mysqli_query($con, $select); while ($row = mysqli_fetch_array($run)){ if ($studentid != $row['studentid']) { $acayear = $row['acayear']; $form = $row['form']; $semester = $row['semester']; $class = $row['class']; $school = $row['school']; $logo = $row['logo']; $studentid = $row['studentid']; $name = $row['name']; $gender = $row['gender']; $program = $row['program']; $class = $row['class']; $house = $row['house']; $image = $row['image']; ?> <div id="heading"> <?php echo "$school"; ?> </div> <div id="logo1"> <img src="../uploads/student/<?php echo $image; ?>" width="100px" class="rounded"> </div> <div id="heading2"> <b> STUDENT ID:</b> <?php echo $studentid; ?><?php echo " "; ?> <?php echo " "; ?> <b>GENDER:</b> <?php echo $gender; ?> <?php echo " "; ?> <?php echo " "; ?><b>PROGRAM:</b><?php echo " "; ?><?php echo $program; ?><br><b>CLASS:</b><?php echo " "; ?><?php echo $class; ?> <?php echo " "; ?><b>HOUSE:</b> <?php echo " "; ?><?php echo $house; ?><?php echo " "; ?><b> ACADEMIC YEAR:</b><?php echo " "; ?><?php echo $acayear; ?><?php echo " "; ?> <br><b> NAME OF STUDENT:</b> <?php echo $name; ?> </div> <div id="logo"> <img src="../uploads/logo/<?php echo $logo; ?>" width="100px" class="rounded"> </div> <br> <div id="heading1"> STUDENT SEMESTER REPORT </div> <div id="tablewrap"> <table class="table table-bordered table-sm" cellspacing="0" width="100%"> <thead> <tr class="text-center"> <th class="th-sm text-center">Subject </th> <th class="th-sm text-center">Class Score <br>(30%) </th> <th class="th-sm text-center">Exam Score <br>(70%) </th> <th class="th-sm text-center">Total <br>(100%) </th> <th class="th-sm text-center">Grade </th> <th class="th-sm text-center">Position </th> <th class="th-sm text-center">Remarks </th> </tr> </thead> <?php }?> <tbody> <?php $subject = $row['subject']; $class_score1 = $row['class_score1']; $exam_score1 = $row['exam_score1']; $total = $row['total']; $grade = $row['grade']; $rank = $row['rank']; $remarks = $row['remarks']; ?> <tr> <td class="text-left"> <?php echo $subject; ?> </td> <td class="text-center"> <?php echo $class_score1; ?> </td> <td class="text-center"> <?php echo $exam_score1; ?> </td> <td class="text-center"> <?php echo $total; ?> </td> <td class="text-center"> <?php echo $grade; ?> </td> <td class="text-center"> <?php echo $rank; ?> </td> <td class="text-left"> <?php echo $remarks; ?> </td> </tr> <?php } ?> </tbody> <tfoot> </tfoot> </table> -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
The expected out is the above picture. Please the query is correct but i use while loop it display as one page -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
<div class="card shadow"> <div class="card-header"><span class="text-primary"></span></div> <div class="card-body"> <div class="formwrap"> <!--###########updateButton Second Form ###########--> <form action="report.php" method="post" enctype="multipart/form-data" autocomplete="off"> <div class="row form-group"> <?php $select1 = "SELECT * FROM acayear"; $result1 = mysqli_query($con, $select1); ?> <div class="col-sm-3"> <label>Academic Year</label> <select name="acayear" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <?php while ($row = mysqli_fetch_array($result1)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select2 = "SELECT * FROM semester"; $result2 = mysqli_query($con, $select2); ?> <div class="col-sm-3"> <label>Semseter</label> <select name="semester" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <?php while ($row = mysqli_fetch_array($result2)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select3 = "SELECT * FROM form WHERE form.form<>'PAST' ORDER BY form.form ASC"; $result3 = mysqli_query($con, $select3); ?> <div class="col-sm-3"> <label>Form</label> <select name="form" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <option value=""></option> <?php while ($row = mysqli_fetch_array($result3)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select4 = "SELECT * FROM class ORDER BY class.class ASC"; $result4 = mysqli_query($con, $select4); ?> <div class="col-sm-3"> <label>Select Class</label> <select name="class" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <option value=""></option> <?php while ($row = mysqli_fetch_array($result4)):; ?> <option value="<?php echo $row[2]; ?>"> <?php echo $row[2]; ?> </option> <?php endwhile; ?> </select> </div> </div> <div class="mt-2 d-grid gap-2 col-6 mx-auto"> <input name="submit" type="submit" class="btn btn-primary btn-sm btn-responsive" value="View Class"> </div> </form> </div> </div> </div> </div> <!--###################################################################################################--> <div class="heading mt-2"> <?php error_reporting(0); ?> <?php if (isset($_POST['submit'])) { $acayear = mysqli_real_escape_string($con, $_POST['acayear']); $semester = mysqli_real_escape_string($con, $_POST['semester']); $form = mysqli_real_escape_string($con, $_POST['form']); $class = mysqli_real_escape_string($con, $_POST['class']); } $select = "SELECT school.school, school.logo, student.gender, student.program, student.house, student.enstatus, student.image, marks.studentid, marks.name, marks.acayear, marks.semester, marks.form, marks.class, marks.subject, marks.class_score1, marks.exam_score1, marks.total, marks.grade, marks.remarks, RANK() OVER (PARTITION BY marks.lessonsid, marks.acayear, marks.form, marks.semester, marks.subject, marks.class ORDER BY marks.total DESC) as rank FROM marks LEFT JOIN student ON marks.studentid=student.studentid LEFT JOIN school ON student.schoolid=school.schoolid WHERE marks.acayear='2024/2025' AND marks.semester='1' AND marks.form='3' AND marks.class='SCI A' ORDER BY marks.name, marks.subject"; ?> <div id="heading"> <?php echo "$school"; ?> </div> <div id="logo1"> <img src="../uploads/student/<?php echo $image; ?>" width="100px" class="rounded"> </div> <div id="heading2"> <b> STUDENT ID:</b> <?php echo $studentid; ?><?php echo " "; ?> <?php echo " "; ?> <b>GENDER:</b> <?php echo $gender; ?> <?php echo " "; ?> <?php echo " "; ?><b>PROGRAM:</b><?php echo " "; ?><?php echo $program; ?><br><b>CLASS:</b><?php echo " "; ?><?php echo $class; ?> <?php echo " "; ?><b>HOUSE:</b> <?php echo " "; ?><?php echo $house; ?><?php echo " "; ?><b> ACADEMIC YEAR:</b><?php echo " "; ?><?php echo $acayear; ?><?php echo " "; ?> <br><b> NAME OF STUDENT:</b> <?php echo $name; ?> </div> <div id="logo"> <img src="../uploads/logo/<?php echo $logo; ?>" width="100px" class="rounded"> </div> <br> <div id="heading1"> STUDENT SEMESTER REPORT </div> <div id="tablewrap"> <table class="table table-bordered table-sm" cellspacing="0" width="100%"> <thead> <tr class="text-center"> <th class="th-sm text-center">Subject </th> <th class="th-sm text-center">Class Score <br>(30%) </th> <th class="th-sm text-center">Exam Score <br>(70%) </th> <th class="th-sm text-center">Total <br>(100%) </th> <th class="th-sm text-center">Grade </th> <th class="th-sm text-center">Position </th> <th class="th-sm text-center">Remarks </th> </tr> </thead> <tbody> <?php $run = mysqli_query($con, $select); if (mysqli_num_rows($run) > 0) { $previd = 0; foreach ($run as $row) { if ($studentid != $previd) { $previd = $studentid; } ?> <tr> <td><?php echo $row['subject']; ?></td> <td><?php echo $row['class_score1']; ?></td> <td><?php echo $row['exam_score1']; ?></td> <td><?php echo $row['total']; ?></td> <td><?php echo $row['grade']; ?></td> <td><?php echo $row['rank']; ?></td> <td><?php echo $row['remarks']; ?></td> </tr> <?php } } else { echo "No Record Found"; } ?> </tbody> <tfoot> </tfoot> </table> </div> </div> </div> <!--end:: -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
-
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
I am still confuse if you can help My code <div class="card shadow"> <div class="card-header"><span class="text-primary"></span></div> <div class="card-body"> <div class="formwrap"> <!--###########updateButton Second Form ###########--> <form action="report1.php" method="post" enctype="multipart/form-data" autocomplete="off"> <div class="row form-group"> <?php $select1 = "SELECT * FROM acayear"; $result1 = mysqli_query($con, $select1); ?> <div class="col-sm-3"> <label>Academic Year</label> <select name="acayear" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <?php while ($row = mysqli_fetch_array($result1)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select2 = "SELECT * FROM semester"; $result2 = mysqli_query($con, $select2); ?> <div class="col-sm-3"> <label>Semseter</label> <select name="semester" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <?php while ($row = mysqli_fetch_array($result2)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select3 = "SELECT * FROM form WHERE form.form<>'PAST' ORDER BY form.form ASC"; $result3 = mysqli_query($con, $select3); ?> <div class="col-sm-3"> <label>Form</label> <select name="form" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <option value=""></option> <?php while ($row = mysqli_fetch_array($result3)):; ?> <option value="<?php echo $row[1]; ?>"> <?php echo $row[1]; ?> </option> <?php endwhile; ?> </select> </div> <?php $select4 = "SELECT * FROM class ORDER BY class.class ASC"; $result4 = mysqli_query($con, $select4); ?> <div class="col-sm-3"> <label>Select Class</label> <select name="class" class="form-select form-select-sm" aria-label=".form-select-sm" required="required"> <option value=""></option> <?php while ($row = mysqli_fetch_array($result4)):; ?> <option value="<?php echo $row[2]; ?>"> <?php echo $row[2]; ?> </option> <?php endwhile; ?> </select> </div> </div> <div class="mt-2 d-grid gap-2 col-6 mx-auto"> <input name="submit" type="submit" class="btn btn-primary btn-sm btn-responsive" value="View Class"> </div> </form> </div> </div> </div> </div> <!--###################################################################################################--> <div class="heading mt-2"> <?php error_reporting(0); ?> <?php if (isset($_POST['submit'])) { $acayear = mysqli_real_escape_string($con, $_POST['acayear']); $semester = mysqli_real_escape_string($con, $_POST['semester']); $form = mysqli_real_escape_string($con, $_POST['form']); $class = mysqli_real_escape_string($con, $_POST['class']); } $select = "SELECT school.school, school.logo, student.studentid,student.name, student.gender, student.program, student.class, student.house, student.enstatus, student.image, marks1.studentid, marks1.name, marks1.acayear, marks1.semester, marks1.form, marks1.class, marks1.subject, marks1.class_score1, marks1.exam_score1, marks1.total, marks1.remarks,marks1.rank FROM marks1 LEFT JOIN student ON marks1.studentid=student.studentid LEFT JOIN school ON student.schoolid=school.schoolid WHERE marks1.acayear='{$acayear}' AND marks1.semester='{$semester}' AND marks1.form='{$form}' AND marks1.class='{$class}' AND student.enstatus='INSCHOOL' GROUP BY marks1.studentid, marks1.name, marks1.class, marks1.subject"; $run = mysqli_query($con, $select); $row = mysqli_fetch_array($run); $marksid = $row['marksid']; $lessonsid = $row['lessonsid']; $acayear = $row['acayear']; $form = $row['form']; $semester = $row['semester']; $class = $row['class']; $school = $row['school']; $logo = $row['logo']; $studentid = $row['studentid']; $name = $row['name']; $gender = $row['gender']; $program = $row['program']; $class = $row['class']; $house = $row['house']; $image = $row['image']; ?> </div> <div id="heading"> <?php echo "$school"; ?> </div> <div id="logo1"> <img src="../uploads/student/<?php echo $image; ?>" width="100px" class="rounded"> </div> <div id="heading2"> <b> STUDENT ID:</b> <?php echo $studentid; ?><?php echo " "; ?> <?php echo " "; ?> <b>GENDER:</b> <?php echo $gender; ?> <?php echo " "; ?> <?php echo " "; ?><b>PROGRAM:</b><?php echo " "; ?><?php echo $program; ?><br><b>CLASS:</b><?php echo " "; ?><?php echo $class; ?> <?php echo " "; ?><b>HOUSE:</b> <?php echo " "; ?><?php echo $house; ?><?php echo " "; ?><b> ACADEMIC YEAR:</b><?php echo " "; ?><?php echo $acayear; ?><?php echo " "; ?> <br><b> NAME OF STUDENT:</b> <?php echo $name; ?> </div> <div id="logo"> <img src="../uploads/logo/<?php echo $logo; ?>" width="100px" class="rounded"> </div> <br> <div id="heading1"> STUDENT SEMESTER REPORT </div> <div id="tablewrap"> <table class="table table-bordered table-sm" cellspacing="0" width="100%"> <thead> <tr class="text-center"> <th class="th-sm text-center">Subject </th> <th class="th-sm text-center">Class Score <br>(30%) </th> <th class="th-sm text-center">Exam Score <br>(70%) </th> <th class="th-sm text-center">Total <br>(100%) </th> <th class="th-sm text-center">Position </th> <th class="th-sm text-center">Remarks </th> </tr> </thead> <tbody> <?php while ($row = mysqli_fetch_array($run)) { $subject = $row['subject']; $class_score1 = $row['class_score1']; $exam_score1 = $row['exam_score1']; $total = $row['total']; $rank = $row['rank']; $remarks = $row['remarks']; ?> <tr> <td class="text-left"> <?php echo $subject; ?> </td> <td class="text-center"> <?php echo $class_score1; ?> </td> <td class="text-center"> <?php echo $exam_score1; ?> </td> <td class="text-center"> <?php echo $total; ?> </td> <td class="text-center"> <?php echo $rank; ?> </td> <td class="text-left"> <?php echo $remarks; ?> </td> </tr> <?php } ?> </tbody> <tfoot> </tfoot> </table> </div> </div> Output -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
I am very grateful for your quick response. i am havin a challenge displaying this in a table using php while loop. All the results are joined together but want each student details and marks seperated. can have any assistance? -
Generate students postions based on marks scored in an exam
sule replied to sule's topic in MySQL Help
I am very grateful for your quick response. i am havin a challenge displaying this in a table using php while loop. All the results are joined together but want each student details and marks seperated. can have any assistance?