CODE

 avatar
unknown
php
2 years ago
3.2 kB
3
Indexable
<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8">
		<title>List of Subjects</title>
		<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
		<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
		<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
		<style>
			.wrapper{
					width: 1000px;
					margin: 0 auto;
			}
			table tr td:last-child{
				width: 120px;
			}
		</style>
	</head>
	<body>
	<div class="wrapper">
			<div class="container-fluid">
				<div class="row">
					<div class="col-md-12">
						<div class="mt-5 mb-3 clearfix">
							<h2 class="pull-left">List of Schedules</h2>
						</div>
						<?php 
							include "connect_to_database.php";
							$sql = "SELECT tbl_subject.subject_id, tbl_subject.subject_code, tbl_schedule.time_in, tbl_schedule.time_out FROM tbl_schedule LEFT JOIN tbl_subject ON tbl_schedule.subject_id=tbl_subject.subject_id";
							if($result = mysqli_query($conn, $sql)){
								if(mysqli_num_rows($result) > 0){
									echo '<table class="table table-bordered table-striped">';
										echo "<thead>";
											echo "<tr>";
												echo "<th>EDP Code</th>";
												echo "<th>Subject Code</th>";
												echo "<th>Description</th>";
												echo "<th>Room</th>";
												echo "<th>Units</th>";
												echo "<th>Day</th>";
												echo "<th>Time In</th>";
												echo "<th>Out</th>";
												echo "<th>Faculty</th>";
											echo "</tr>";
										echo "</thead>";
										echo "<tbody>";
										while($row = mysqli_fetch_array($result)){
											$time_id = $row['time_out'];
											$sql1 = "SELECT * FROM tbl_time WHERE tbl_time_id='$time_id'";
											$result1 = mysqli_query($conn, $sql1);
											$result1 = mysqli_fetch_assoc($result1);
												echo "<tr>";
													echo "<td>" . $row['edp_code'] . "</td>";
													echo "<td>" . $row['subject_code'] . "</td>";
													echo "<td>" . $row['description'] . "</td>";
													echo "<td>" . $row['room'] . "</td>";
													echo "<td>" . $row['unit'] . "</td>";
													echo "<td>" . $row['day'] . "</td>";
													echo "<td>" . date("g:i a", strtotime($row['tbl_time_list'])) . "</td>";
													echo "<td>" . date("g:i a", strtotime($result1['tbl_time_list'])) . "</td>";
													echo "<td>" . $row['faculty'] . "</td>";
													echo "</td>";
												echo "</tr>";
											}
										echo "</tbody>";
									echo "</table>";
									mysqli_free_result($result);
								} else {
									echo '<div class="alert alert-danger"><em>No records were found.</em></div>';
								}
							} else {
								echo "Oops!<br>Something went wrong.<br>Please try again later.";
							}
							mysqli_close($conn);
						?>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
Editor is loading...