I have values in my attendance table as follows
sl_no is Foreign key reference register_table( sl_no
)
register_table Contains details about students like student_name etc...
My question is ,
How can i get Attendance report in Table Format (Like Excel) Using Multi dimentional Array
UPDATE
I'm Querying the database as below, but am getting the results of same students in multiple rows, wherever they present it will create NEW ROW, I'm expecting to display in table format with different dates header for the same student name by using 2 dimensional array.
$sql="SELECT att.present,att.AttDate,r.student_name,r.university,r.batch FROM register_table as r inner join attendance as att on r.sl_no=att.sl_no WHERE university LIKE '$sdluniversity'";
$result=mysqli_query($link, $sql);
while ($row = mysqli_fetch_array($result, MYSQL_ASSOC)) {
echo "<tr>";
echo "<td>".$row['student_name']."</td>";
echo "<td>".$row['present']."</td>";
echo "<td>".$row['AttDate']."</td>";
echo "<td>".$row['university']."</td>";
echo "<td>".$row['batch']."</td>";
echo "</tr>";
}
Please Suggest me what are all the changes I need to make in the above code or my code is totally wrong to achieve my requirement.
I would like the output to look like this :
Date1 Date1 Date3 University Batch Average
Student1 present present present Myuniversity 2012 100%
Student2 present Absent Absent Myuniversity 2013 33%
Student3 present present present Myuniversity 2012 100%
Like Excel Attendance Report, As I'm New webie Any help may greatly appreciated.
Use inner join on tables as
$sql='select att.present,r.university,r.name,r.rollNo from register as r inner join attendance as att on r.sl_no=att.sl_no';
$sql = mysqli_query($con, $query);
$attendence = array();
while ($data = mysqli_fetch_assoc($sql)){
if (!array_key_exists($data['userId'], $attendence))
$attendence[$data['userId']]['student'] = $data['userId'];
$attendence[$data['userId']][$data['date']] = $data['present'];
}
echo "<pre>";
var_dump($attendence);
iterate each index of $attendence
array to form a table having index as userId,dates you can also calculate average of their attendance
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.