Jump to content

Zinn

Members
  • Posts

    15
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Zinn's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi @mac_gyver Thank you for your best and valuable advice. I will follow all these rules and learn more. Thank you once again. Kind regards,
  2. Hello Coders, wanted to know if anybody could help to validate modal form based on the query below please? Appreciate your help if possible. Thank you so much! MODAL FORM FORM <div class="modal fade" id="exampleModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="staticBackdrop" aria-hidden="true"> > <div class="modal-dialog" role="document"> <div class="modal-content"> <div class="modal-header"> <h5 class="modal-title" id="exampleModalLabel">Add user</h5> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <i aria-hidden="true" class="ki ki-close"></i> </button> </div> <div class="modal-body"> <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post" class="needs-validation" novalidate id="adduser"> <div class="form-row"> <div class="form-group col-md-6 mb-3"> <label for="inputState">Select a name</label><br> <select class="form-control select2 <?php echo (!empty($fullname_err)) ? 'is-invalid' : ''; ?>" id="kt_select2_1" name="fullname" required> <option value="" selected>Select a name</option> <?php require_once('./conn/inc.php'); $sql = mysqli_query($link,"SELECT * FROM members ORDER BY fullname ASC"); while($row=mysqli_fetch_array($sql)) { $mid = $row['mid']; $fullname = $row['fullname']; echo '<option value="'.$mid.'">'.$fullname.'</option>'; } ?> </select> <span class="invalid-feedback"><?php echo $fullname_err; ?></span> </div> <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-12 mb-3"> <label for="username">Username</label> <input type="text" class="form-control <?php echo (!empty($uname_err)) ? 'is-invalid' : ''; ?>" placeholder="username" name="uname" required> <span class="invalid-feedback"><?php echo $uname_err; ?></span> </div> <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-12 mb-3"> <label for="showpass">Password</label> <input type="password" class="form-control <?php echo (!empty($password_err)) ? 'is-invalid' : ''; ?>" id="showpass" placeholder="Password" name="password" required> <span class="invalid-feedback"><?php echo $password_err; ?></span> </div> <div class="col-xxl-6 col-xl-6 col-lg-6 col-md-6 col-sm-12 mb-3"> <label for="showpass2">Confirm Password</label> <input type="password" name="confirm_password" class="form-control <?php echo (!empty($confirm_password_err)) ? 'is-invalid' : ''; ?>" id="showpass2" placeholder="Confirm password" required> <span class="invalid-feedback"><?php echo $confirm_password_err; ?></span> </div> </div> </div> <div class="modal-footer"> <div class="checkbox-inline mr-2"> <label class="checkbox"> <input type="checkbox" onclick="myFunction()" class="form-check-input" id="exampleCheck1"> <span></span> Show password </label> </div> <button type="reset" class="btn btn-secondary">Clear</button> <button type="submit" class="btn btn-primary">Submit</button> </div> </form> </div> </div> </div> VALIDATION QUERY <?php // Define variables and initialize with empty values $fullname = $uname = $password = $confirm_password = ""; $fullname_err = $uname_err = $password_err = $confirm_password_err = ""; // Processing form data when form is submitted if($_SERVER["REQUEST_METHOD"] == "POST"){ // Validate username if(empty(trim($_POST["uname"]))){ $uname_err = "Please enter a username."; } elseif(!preg_match('/^[a-zA-Z0-9_]+$/', trim($_POST["uname"]))){ $uname_err = "Username can only contain letters, numbers, and underscores."; } else{ // Prepare a select statement $sql = "SELECT id FROM users WHERE uname = ?"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "s", $param_username); // Set parameters $param_username = trim($_POST["uname"]); // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ /* store result */ mysqli_stmt_store_result($stmt); if(mysqli_stmt_num_rows($stmt) == 1){ $uname_err = "This username is already taken."; } else{ $uname = trim($_POST["uname"]); } } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Validate username if(empty(trim($_POST["fullname"]))){ $fullname_err = "Please enter a fullname."; } else{ // Prepare a select statement $sql = "SELECT id FROM users WHERE fullname = ?"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "s", $param_fullname); // Set parameters $param_fullname = trim($_POST["fullname"]); // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ /* store result */ mysqli_stmt_store_result($stmt); if(mysqli_stmt_num_rows($stmt) == 1){ $fullname_err = "This names is already taken."; } else{ $fullname = trim($_POST["fullname"]); } } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Validate password if(empty(trim($_POST["password"]))){ $password_err = "Please enter a password."; } elseif(strlen(trim($_POST["password"])) < 6){ $password_err = "Password must have atleast 6 characters."; } else{ $password = trim($_POST["password"]); } // Validate confirm password if(empty(trim($_POST["confirm_password"]))){ $confirm_password_err = "Please confirm password."; } else{ $confirm_password = trim($_POST["confirm_password"]); if(empty($password_err) && ($password != $confirm_password)){ $confirm_password_err = "Password did not match."; } } // Check input errors before inserting in database if(empty($fullname_err) && empty($uname_err) && empty($password_err) && empty($confirm_password_err)){ $fullname = mysqli_real_escape_string($link, $_REQUEST['fullname']); $uname = mysqli_real_escape_string($link, $_REQUEST['uname']); // Prepare an insert statement $sql = "INSERT INTO users (fullname, uname, password) VALUES (?, ?, ?)"; if($stmt = mysqli_prepare($link, $sql)){ // Bind variables to the prepared statement as parameters mysqli_stmt_bind_param($stmt, "sss", $param_fullname, $param_username, $param_password); // Set parameters $param_fullname = $fullname; $param_username = $uname; $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash // Attempt to execute the prepared statement if(mysqli_stmt_execute($stmt)){ // Redirect to login page header("location: users.php"); $_SESSION['status'] = "Record Successfuly Saved!"; } else{ echo "Oops! Something went wrong. Please try again later."; } // Close statement mysqli_stmt_close($stmt); } } // Close connection // mysqli_close($link); } ?> I have put javascript to validate form before submitting and this only works on client side ; It won't fetch data from database to compare. <script> // Example starter JavaScript for disabling form submissions if there are invalid fields (function() { 'use strict'; window.addEventListener('load', function() { // Fetch all the forms we want to apply custom Bootstrap validation styles to var forms = document.getElementsByClassName('needs-validation'); // Loop over them and prevent submission var validation = Array.prototype.filter.call(forms, function(form) { form.addEventListener('submit', function(event) { if (form.checkValidity() === false) { event.preventDefault(); event.stopPropagation(); } form.classList.add('was-validated'); }, false); }); }, false); })(); </script>
  3. Thank you once again for your advice @Barand definitely, I will delete those duplicate fields. The problem with this project is that; Our checker wanted to inlucude REPLAY column 2/6(Thrusday) to LIVE column 1/6(Wed). So that Replay on the following day data will still display on Live column which is 1/6(wed). But anyway, I will find solution to this and I have in mind already. Thank you, you've been an inspiration to us to learn more.
  4. Thank you @Barand I will use this as reference, I found a solution to capture all services with replay and live service now. With this code, I now able to display only 3 services per week by putting dayofweek field on both services and attendance table and compare instead of entrydate of attendance = dayofweek of services. Than you so much for your help. Kind regards, Zin
  5. Hi Sir @Barand, Yes sir I did but the results still the same. serid = WS for example should only occupy 1 column regardless of the date they register attendance in a week. Cause if user cannot join the Live worship they will join on the next day but replay.
  6. Hi Sir @Barand You've got it right and your code really helps me a lot. However is there a way to DISTINCT serid and the HEADER Date will based only on LIVE VIEWING? So that every week there are only 3 services columns are being displayed. On my table i have stype where if stype = 1 it is (LIVE) and stype = 2 (replay). I tried GROUP_CONCAT but doesn't work well. Hope you understand me and PDO for me is a new thing cause am used to MYSQLI. Way more to go to learn. Thank you so much for your patience. Kind regards,
  7. Hello @Phi11W Yes correct! I got Barand's idea and I will follow this best idea than my complex one. You have a good point and thank you for your initiative. Appreciate your help guys. I will update here once everything set on my end. Thank you so much. Regards, Zin
  8. Dear Sir @Barand Thank you so much for your big big help. Appreciate for your best help and solution on our headache as beginner. I will update you once i've executed this query. Thank you so much once again! Best regards,
  9. Thank you so much @Barand Sir, Definitly try this one and let you know. The thing is, I get this value (1) of enabled if users will try to submit attendance. And if that user is late, she will no longer be able to submit attendance. Thank you.
  10. Hello Coding Masters, Thank you for reading my post. I need your help if if it's possible that Database table value will automatically update the value when time expires? Sample, If now time is is between ENTRYTime and CLOSE Time, table value will automatically update if time set expires? Enabled value is = 0 on my table Disabled value is = 0 on my table. But I have someone close to me suggested if its possible to set these automatically? Thank you so much for your feedback.
  11. Hi Sir @Barand I've added the Group already on my database and deleted some fields on it. -- phpMyAdmin SQL Dump -- version 5.2.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jun 08, 2022 at 11:27 AM -- Server version: 10.4.24-MariaDB -- PHP Version: 8.1.6 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `mcgibn` -- -- -------------------------------------------------------- -- -- Table structure for table `attendance` -- CREATE TABLE `attendance` ( `atid` int(11) NOT NULL, `memid` int(11) NOT NULL, `serid` int(11) NOT NULL, `calid` int(11) NOT NULL, `grid` varchar(10) CHARACTER SET latin1 NOT NULL, `entrydate` timestamp NOT NULL DEFAULT current_timestamp(), `month` varchar(30) CHARACTER SET latin1 NOT NULL, `year` varchar(5) DEFAULT NULL, `updatedat` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `viewfrom` int(11) NOT NULL, `astatus` int(11) NOT NULL, `stype` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `attendance` -- INSERT INTO `attendance` (`atid`, `memid`, `serid`, `calid`, `grid`, `entrydate`, `month`, `year`, `updatedat`, `viewfrom`, `astatus`, `stype`) VALUES (32, 37, 1, 1, '', '2022-05-31 12:55:28', 'May', '2022', '2022-05-31 12:55:28', 0, 1, 2), (33, 37, 2, 1, '', '2022-05-31 12:55:36', 'May', '2022', '2022-05-31 12:55:36', 0, 1, 1), (34, 37, 3, 1, '', '2022-05-31 12:55:43', 'May', '2022', '2022-06-01 03:28:55', 0, 1, 1), (35, 37, 1, 0, '', '2022-05-31 12:56:15', 'Jun', '2022', '2022-06-01 01:17:35', 0, 1, 2), (36, 37, 2, 1, '', '2022-05-31 12:56:25', 'Jun', '2022', '2022-06-01 01:17:35', 0, 1, 1), (37, 37, 3, 1, '', '2022-05-31 12:56:40', 'Jun', '2022', '2022-06-01 01:17:35', 0, 1, 1), (38, 37, 1, 1, '', '2022-05-31 12:57:24', 'May', '2023', '2022-05-31 12:57:24', 0, 1, 2), (39, 37, 2, 1, '', '2022-05-31 12:57:37', 'May', '2023', '2022-05-31 12:57:37', 0, 1, 1), (40, 37, 3, 1, '', '2022-05-31 12:57:46', 'May', '2023', '2022-05-31 12:57:46', 0, 1, 1), (41, 37, 1, 1, '', '2022-05-31 12:57:57', 'Jun', '2023', '2022-06-01 01:17:35', 0, 1, 2), (42, 37, 2, 1, '', '2022-05-31 12:58:08', 'Jun', '2023', '2022-06-01 01:17:35', 0, 1, 1), (43, 37, 3, 1, '', '2022-05-31 12:58:18', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 1), (44, 49, 1, 1, '', '2022-05-31 12:58:32', 'May', '2022', '2022-05-31 12:58:32', 0, 1, 2), (45, 49, 2, 1, '', '2022-05-31 12:58:40', 'May', '2022', '2022-05-31 12:58:40', 0, 1, 1), (47, 49, 1, 1, '', '2022-05-31 12:59:01', 'Jun', '2022', '0000-00-00 00:00:00', 0, 1, 2), (48, 49, 2, 1, '', '2022-05-31 12:59:14', 'Jun', '2022', '2022-06-01 01:12:40', 0, 1, 1), (49, 49, 3, 1, '', '2022-05-18 12:59:31', 'Jun', '2022', '2022-06-06 08:45:28', 0, 1, 1), (50, 49, 1, 1, '', '2022-05-31 12:59:41', 'May', '2023', '2022-05-31 12:59:41', 0, 1, 2), (51, 49, 2, 1, '', '2022-05-31 12:59:49', 'May', '2023', '2022-05-31 12:59:49', 0, 1, 1), (52, 49, 3, 1, '', '2022-05-31 13:00:05', 'May', '2023', '2022-05-31 13:00:05', 0, 1, 1), (53, 49, 1, 1, '', '2022-05-31 13:00:21', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 2), (54, 49, 2, 1, '', '2022-05-31 13:00:32', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 1), (55, 49, 3, 1, '', '2022-05-31 13:00:43', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 1), (56, 88, 1, 1, '', '2022-05-31 13:01:25', 'May', '2022', '2022-05-31 13:01:25', 0, 1, 2), (57, 88, 2, 1, '', '2022-05-31 13:01:30', 'May', '2022', '2022-05-31 13:01:30', 0, 1, 1), (58, 88, 3, 1, '', '2022-05-31 13:01:37', 'May', '2022', '2022-05-31 13:01:37', 0, 1, 1), (59, 88, 1, 1, '', '2022-05-31 13:01:45', 'Jun', '2022', '2022-06-01 01:27:00', 0, 1, 2), (60, 88, 2, 1, '', '2022-05-31 13:01:52', 'Jun', '2022', '2022-06-01 01:12:40', 0, 1, 1), (62, 88, 1, 1, '', '2022-05-31 13:02:37', 'Jun', '2023', '2022-06-01 01:27:07', 0, 1, 2), (63, 88, 2, 1, '', '2022-05-31 13:02:54', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 1), (64, 88, 3, 1, '', '2022-05-31 13:03:04', 'Jun', '2023', '2022-06-01 01:27:10', 0, 1, 1), (65, 88, 1, 1, '', '2022-05-31 13:03:14', 'May', '2023', '2022-05-31 13:03:14', 0, 1, 2), (66, 88, 2, 1, '', '2022-05-31 13:03:22', 'May', '2023', '2022-05-31 13:03:22', 0, 1, 1), (67, 88, 3, 1, '', '2022-05-31 13:03:31', 'May', '2023', '2022-05-31 13:03:31', 0, 1, 1), (68, 89, 1, 1, '', '2022-05-31 13:04:21', 'May', '2022', '2022-05-31 13:04:21', 0, 1, 2), (69, 89, 2, 1, '', '2022-05-31 13:04:34', 'May', '2022', '2022-05-31 13:04:34', 0, 1, 1), (70, 89, 3, 1, '', '2022-05-31 13:04:40', 'May', '2022', '2022-05-31 13:04:40', 0, 1, 1), (71, 89, 1, 1, '', '2022-05-31 13:04:49', 'Jun', '2022', '2022-06-01 01:12:40', 0, 1, 2), (72, 89, 2, 1, '', '2022-05-31 13:04:56', 'Jun', '2022', '2022-06-01 01:12:40', 0, 1, 1), (73, 89, 3, 1, '', '2022-05-18 13:05:14', 'Jun', '2022', '2022-06-06 08:45:15', 0, 1, 1), (74, 89, 1, 1, '', '2022-05-31 13:05:24', 'May', '2023', '2022-05-31 13:05:24', 0, 1, 2), (75, 89, 2, 1, '', '2022-05-31 13:05:31', 'May', '2023', '2022-05-31 13:05:31', 0, 1, 1), (76, 89, 3, 1, '', '2022-05-31 13:05:41', 'May', '2023', '2022-05-31 13:05:41', 0, 1, 1), (77, 89, 1, 1, '', '2022-05-31 13:05:51', 'Jun', '2023', '2022-06-01 01:12:40', 0, 1, 2), (78, 89, 2, 1, '', '2022-05-31 13:05:59', 'Jun', '2023', '0000-00-00 00:00:00', 0, 1, 1), (79, 89, 3, 1, '', '2022-05-31 13:06:09', 'Jun', '2023', '2022-06-01 01:27:12', 0, 1, 1), (80, 84, 1, 1, '', '2022-05-31 13:07:19', 'May', '2022', '2022-06-01 03:40:25', 0, 1, 2), (81, 84, 2, 1, '', '2022-05-31 13:07:24', 'May', '2022', '2022-05-31 13:07:24', 0, 1, 1), (82, 84, 3, 1, '', '2022-05-31 13:07:31', 'May', '2022', '2022-06-01 03:42:52', 0, 1, 1), (83, 84, 1, 1, '', '2022-05-31 13:07:38', 'Jun', '2022', '2022-06-01 01:12:40', 0, 1, 2), (84, 84, 2, 1, '', '2022-05-31 13:07:45', 'Jun', '2022', '2022-06-01 01:27:14', 0, 1, 1), (85, 84, 3, 1, '', '2022-05-31 13:07:53', 'Jun', '2022', '2022-06-01 01:27:16', 0, 1, 1), (86, 84, 1, 1, '', '2022-05-31 13:08:12', 'May', '2023', '2022-05-31 13:08:12', 0, 1, 2), (87, 84, 2, 1, '', '2022-05-31 13:08:23', 'May', '2023', '2022-05-31 13:08:23', 0, 1, 1), (88, 84, 3, 1, '', '2022-05-31 13:08:30', 'May', '2023', '2022-05-31 13:08:30', 0, 1, 1), (89, 84, 1, 1, '', '2022-05-31 13:08:44', 'Jun', '2023', '2022-06-01 01:27:20', 0, 1, 2), (90, 84, 2, 1, '', '2022-05-31 13:08:58', 'Jun', '2023', '2022-06-01 01:27:22', 0, 1, 1), (91, 84, 3, 1, '', '2022-05-31 13:09:06', 'Jun', '2023', '2022-06-01 01:27:26', 0, 1, 1), (92, 121, 1, 1, '', '2022-05-31 13:09:59', 'May', '2022', '2022-05-31 13:09:59', 0, 1, 2), (93, 121, 2, 1, '', '2022-05-31 13:10:06', 'May', '2022', '2022-05-31 13:10:06', 0, 1, 1), (94, 121, 3, 1, '', '2022-05-31 13:10:13', 'May', '2022', '2022-05-31 13:10:13', 0, 1, 1), (95, 121, 1, 1, '', '2022-05-31 13:10:20', 'Jun', '2022', '2022-06-01 01:27:27', 0, 1, 2), (96, 121, 2, 1, '', '2022-05-31 13:10:29', 'Jun', '2022', '2022-06-01 08:54:39', 1, 1, 1), (97, 121, 3, 1, '', '2022-05-31 13:10:38', 'Jun', '2022', '2022-06-01 01:27:30', 0, 1, 1), (98, 121, 1, 1, '', '2022-05-31 13:10:50', 'May', '2023', '2022-05-31 13:10:50', 0, 1, 2), (99, 121, 2, 1, '', '2022-05-31 13:10:57', 'May', '2023', '2022-05-31 13:10:57', 0, 1, 1), (100, 121, 3, 1, '', '2022-05-31 13:11:11', 'May', '2023', '2022-05-31 13:11:11', 0, 1, 1), (101, 107, 1, 1, '', '2022-05-31 13:11:34', 'May', '2022', '2022-05-31 13:11:34', 0, 1, 2), (102, 107, 2, 1, '', '2022-05-31 13:11:39', 'May', '2022', '2022-05-31 13:11:39', 0, 1, 1), (103, 107, 3, 1, '', '2022-05-31 13:11:44', 'May', '2022', '2022-05-31 13:11:44', 0, 1, 1), (104, 107, 1, 1, '', '2022-05-31 13:11:51', 'Jun', '2022', '2022-06-01 01:10:41', 0, 1, 2), (105, 107, 2, 1, '', '2022-05-31 13:12:05', 'Jun', '2022', '2022-06-01 01:27:32', 0, 1, 1), (106, 107, 3, 1, '', '2022-05-28 13:12:14', 'Jun', '2022', '2022-06-06 08:45:05', 0, 1, 1), (107, 107, 1, 1, '', '2022-05-31 13:12:28', 'May', '2023', '2022-05-31 13:12:28', 0, 1, 2), (108, 107, 2, 1, '', '2022-05-31 13:12:37', 'May', '2023', '2022-05-31 13:12:37', 0, 1, 1), (109, 107, 3, 1, '', '2022-05-31 13:12:45', 'May', '2023', '2022-05-31 13:12:45', 0, 1, 1), (110, 107, 1, 1, '', '2022-05-31 13:12:56', 'Jun', '2023', '2022-06-01 01:27:36', 0, 1, 2), (111, 107, 2, 1, '', '2022-05-31 13:13:05', 'Jun', '2023', '2022-06-01 01:27:38', 0, 1, 1), (112, 107, 3, 1, '', '2022-05-31 13:17:28', 'Jun', '2023', '2022-06-01 01:27:40', 0, 1, 1), (113, 113, 1, 1, '', '2022-05-31 13:18:57', 'May', '2022', '2022-05-31 13:18:57', 0, 1, 1), (114, 113, 2, 1, '', '2022-05-31 13:19:04', 'May', '2022', '2022-05-31 13:19:04', 0, 1, 1), (115, 113, 3, 1, '', '2022-05-31 13:19:10', 'May', '2022', '2022-05-31 13:19:10', 0, 1, 1), (116, 113, 1, 1, '', '2022-05-31 13:19:18', 'Jun', '2022', '2022-06-01 01:10:41', 0, 1, 1), (117, 113, 2, 1, '', '2022-05-31 13:19:24', 'Jun', '2022', '2022-06-01 01:27:41', 0, 1, 1), (118, 113, 3, 1, '', '2022-05-31 13:19:31', 'Jun', '2022', '2022-06-01 07:57:43', 0, 1, 1), (119, 113, 1, 1, '', '2022-05-31 13:19:41', 'May', '2023', '2022-05-31 13:19:41', 0, 1, 1), (120, 113, 2, 1, '', '2022-05-31 13:19:48', 'May', '2023', '2022-05-31 13:19:48', 0, 1, 1), (121, 113, 3, 1, '', '2022-05-31 13:19:54', 'May', '2023', '2022-05-31 13:19:54', 0, 1, 1), (122, 113, 1, 1, '', '2022-05-31 13:20:04', 'Jun', '2023', '2022-06-01 01:27:45', 0, 1, 1), (123, 113, 2, 1, '', '2022-05-31 13:20:13', 'Jun', '2023', '2022-06-01 01:27:49', 0, 1, 1), (124, 113, 3, 1, '', '2022-05-31 13:20:22', 'Jun', '2023', '2022-06-01 01:27:53', 0, 1, 1), (125, 119, 1, 1, '', '2022-05-31 13:21:12', 'May', '2022', '2022-05-31 13:21:12', 0, 1, 1), (126, 119, 2, 1, '', '2022-05-31 13:21:18', 'May', '2022', '2022-05-31 13:21:18', 0, 1, 1), (127, 119, 3, 1, '', '2022-05-31 13:21:29', 'May', '2022', '2022-05-31 13:21:29', 0, 1, 1), (128, 119, 1, 1, '', '2022-05-31 13:21:45', 'Jun', '2022', '2022-06-01 01:27:54', 0, 1, 1), (129, 119, 2, 1, '', '2022-05-31 13:21:53', 'Jun', '2022', '2022-06-01 01:27:56', 0, 1, 1), (130, 119, 3, 1, '', '2022-05-31 13:22:16', 'Jun', '2022', '2022-06-01 01:28:00', 0, 1, 1), (131, 119, 1, 1, '', '2022-05-31 13:22:24', 'May', '2023', '2022-05-31 13:22:24', 0, 1, 1), (132, 119, 2, 1, '', '2022-05-31 13:22:30', 'May', '2023', '2022-05-31 13:22:30', 0, 1, 1), (133, 119, 3, 1, '', '2022-05-31 13:22:36', 'May', '2023', '2022-05-31 13:22:36', 0, 1, 1), (134, 119, 1, 1, '', '2022-05-31 13:22:45', 'Jun', '2023', '2022-06-01 01:28:03', 0, 1, 1), (135, 119, 2, 1, '', '2022-05-31 13:22:53', 'Jun', '2023', '2022-06-01 01:28:04', 0, 1, 1), (136, 119, 3, 1, '', '2022-05-31 13:23:10', 'Jun', '2023', '2022-06-01 01:28:08', 0, 1, 1), (137, 13, 1, 1, '', '2022-05-31 13:40:26', 'May', '2022', '2022-05-31 13:40:26', 0, 1, 1), (138, 13, 2, 1, '', '2022-05-31 13:40:31', 'May', '2022', '2022-05-31 13:40:31', 0, 1, 1), (139, 13, 3, 1, '', '2022-05-31 13:40:36', 'May', '2022', '2022-05-31 13:40:36', 0, 1, 1), (140, 13, 1, 1, '', '2022-05-31 13:40:42', 'Jun', '2022', '2022-06-01 01:28:10', 0, 1, 1), (141, 13, 2, 1, '', '2022-05-31 13:40:53', 'Jun', '2022', '2022-06-01 01:28:11', 0, 1, 1), (142, 13, 3, 1, '', '2022-05-27 13:41:11', 'Jun', '2022', '2022-06-06 08:44:57', 0, 1, 1), (143, 116, 2, 1, '', '2022-06-08 02:15:40', 'Jun', '2022', '2022-06-08 03:33:25', 0, 1, 2), (144, 47, 2, 1, '', '2022-06-08 02:37:21', 'Jun', '2022', '2022-06-08 03:33:21', 0, 1, 3), (145, 50, 2, 1, '', '2022-06-08 02:39:45', 'Jun', '2022', '2022-06-08 03:33:19', 0, 1, 3), (146, 104, 2, 1, '', '2022-06-08 02:46:37', 'Jun', '2022', '2022-06-08 03:33:17', 0, 1, 3), (147, 27, 2, 1, '', '2022-06-08 03:16:47', 'Jun', '2022', '2022-06-08 03:33:14', 0, 1, 3), (148, 104, 1, 1, '', '2022-06-08 03:32:02', 'Jun', '2022', '2022-06-08 03:32:02', 0, 1, 2), (149, 28, 2, 1, '', '2022-06-08 03:34:00', 'Jun', '2022', '2022-06-08 03:34:00', 0, 1, 1), (150, 106, 3, 1, '', '2022-06-08 03:34:53', 'Jun', '2022', '2022-06-08 03:34:53', 0, 1, 1), (151, 99, 1, 1, '', '2022-06-08 03:36:44', 'Jun', '2022', '2022-06-08 03:36:53', 1, 1, 2), (152, 76, 2, 1, '', '2022-06-08 03:50:48', 'Jun', '2022', '2022-06-08 03:50:48', 0, 1, 1), (153, 28, 1, 1, '', '2022-06-08 04:19:41', 'Jun', '2022', '2022-06-08 04:19:41', 0, 1, 2), (155, 106, 1, 1, '', '2022-06-08 05:46:10', 'Jun', '2022', '2022-06-08 05:46:10', 0, 1, 2), (156, 77, 2, 1, 'G7', '2022-06-08 06:07:28', 'Jun', '2022', '2022-06-08 06:07:28', 0, 1, 1), (157, 102, 2, 1, 'G9', '2022-06-08 09:27:22', 'Jun', '2022', '2022-06-08 09:27:22', 0, 1, 1); -- -- Indexes for dumped tables -- -- -- Indexes for table `attendance` -- ALTER TABLE `attendance` ADD PRIMARY KEY (`atid`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `attendance` -- ALTER TABLE `attendance` MODIFY `atid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=158; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; Just for your reference. Thank you very much for your help and well appreciated.
  12. Hi Sir @Barand By the way each week, there's only potential 3 colums for services (PM/WS/PBB); but since a month contains 5 weeks sometimes, there's are 18 or less expected columns every month. Except for D1/D2/D3 cause this will happen only every quarter of the month. For LS just don't mind. Thank you so much sir.
  13. Hi Sir @Barand Appreciate your help and feedback. Yes the Group # is in member table along with the name, but I did not put the GID or Groupid in attendance table. calid is the Calendar ID which are (1st week / 2nd Week / 3rd week and etc) WS - Stand as worship service every Saturday morning PM - Stand as Prayer meeting every Wednesday PBB - Stand as Thanks Giving every saturday Night. However D1/D2/D3 - Will only happen every quarter of the year, so in one year (it's a 3 days thanksgiving) So Serid or Service ID will only occur once a week (serid here is join from Service table) Yes this can be a potential output, however the date here is not exacly all on May 31 cause I've added these data on May 31 that date.
  14. Hi Sir @Barand Here's the thing I want to achieve, and I do belived that the code you've recreated was your code as well way back 2014 from this post: https://forums.phpfreaks.com/topic/285398-pivot-table-or-cross-tab-in-php-using-mysql-for-attendance/ I tried it and modified but it but it has different results than expected. Here's the code: <?php if(isset($_POST['search'])) { $search = $_POST['search'] ?? ''; $year = $_POST['year'] ?? ''; $month = $_POST['month'] ?? ''; $sql = "SELECT DISTINCT entrydate FROM attendance where stype = 1 and year='$year' and month = '$month' ORDER BY entrydate"; $res = $link->query($sql); // mysqli query while ($row = $res->fetch_row()) { $dates[] = $row[0]; } /*********************************** * Table headings * ************************************/ $emptyRow = array_fill_keys($dates,''); // format dates foreach ($dates as $k=>$v) { $dates[$k] = date('d-M', strtotime($v)); } $heads = "<table border='1'>\n"; $heads .= "<tr><th>Name</th><th>" . join('</th><th>', $dates) . "</th></tr>\n"; /*********************************** * Main data * ************************************/ $sql = "SELECT entrydate, memid, astatus FROM attendance where stype = 1 and year='$year' and month = '$month' ORDER BY memid"; $res = $link->query($sql); $curname=''; $tdata = ''; $rowdata = ''; while (list($d, $sn, $s) = $res->fetch_row()) { if ($curname != $sn) { if ($curname) { $tdata .= "<tr><td>$curname</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n"; } $rowdata = $emptyRow; $curname = $sn; } $rowdata[$d] = $s; } $tdata .= "<tr><td>$curname</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n"; $tdata .= "</table\n"; } ?> </table> <?php echo $heads; echo $tdata; ?> And here's the result: But I want to acheived like belo w that Entrydate is supposed to be dynamic and placed as a Column header for table. Notes: memid = Member name serid = Services like (PM, PBB, WS) calid = 1st Week, 2nd Week and so-on. entrydate = TimeIn date. Thank you and hope you could help.
  15. Hello There, Anyone wants to help me how to achive this thing on PHP? I have zero knowledge on Pibot table for PHP Mysqli and minimal knowledge on programming. Here's the link for output And below is the Table Attendance: -- phpMyAdmin SQL Dump -- version 5.2.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jun 01, 2022 at 10:29 AM -- Server version: 10.4.24-MariaDB -- PHP Version: 8.1.6 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `mcgibn` -- -- -------------------------------------------------------- -- -- Table structure for table `attendance` -- CREATE TABLE `attendance` ( `atid` int(11) NOT NULL, `memid` int(11) NOT NULL, `serid` int(11) NOT NULL, `calid` int(11) NOT NULL, `entrydate` timestamp NOT NULL DEFAULT current_timestamp(), `month` varchar(30) CHARACTER SET latin1 NOT NULL, `year` varchar(5) DEFAULT NULL, `createdat` timestamp NOT NULL DEFAULT current_timestamp(), `updatedat` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(), `viewfrom` int(11) NOT NULL, `astatus` int(11) NOT NULL, `stype` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; -- -- Dumping data for table `attendance` -- INSERT INTO `attendance` (`atid`, `memid`, `serid`, `calid`, `entrydate`, `month`, `year`, `createdat`, `updatedat`, `viewfrom`, `astatus`, `stype`) VALUES (32, 37, 1, 1, '2022-05-31 12:55:28', 'May', '2022', '2022-05-31 12:55:28', '2022-05-31 12:55:28', 0, 1, 2), (33, 37, 2, 1, '2022-05-31 12:55:36', 'May', '2022', '2022-05-31 12:55:36', '2022-05-31 12:55:36', 0, 1, 1), (34, 37, 3, 1, '2022-05-31 12:55:43', 'May', '2022', '2022-05-31 12:55:43', '2022-06-01 03:28:55', 0, 1, 1), (35, 37, 1, 0, '2022-05-31 12:56:15', 'Jun', '2022', '2022-05-31 12:56:15', '2022-06-01 01:17:35', 0, 1, 2), (36, 37, 2, 1, '2022-05-31 12:56:25', 'Jun', '2022', '2022-05-31 12:56:25', '2022-06-01 01:17:35', 0, 1, 1), (37, 37, 3, 1, '2022-05-31 12:56:40', 'Jun', '2022', '2022-05-31 12:56:40', '2022-06-01 01:17:35', 0, 1, 1), (38, 37, 1, 1, '2022-05-31 12:57:24', 'May', '2023', '2022-05-31 12:57:24', '2022-05-31 12:57:24', 0, 1, 2), (39, 37, 2, 1, '2022-05-31 12:57:37', 'May', '2023', '2022-05-31 12:57:37', '2022-05-31 12:57:37', 0, 1, 1), (40, 37, 3, 1, '2022-05-31 12:57:46', 'May', '2023', '2022-05-31 12:57:46', '2022-05-31 12:57:46', 0, 1, 1), (41, 37, 1, 1, '2022-05-31 12:57:57', 'Jun', '2023', '2022-05-31 12:57:57', '2022-06-01 01:17:35', 0, 1, 2), (42, 37, 2, 1, '2022-05-31 12:58:08', 'Jun', '2023', '2022-05-31 12:58:08', '2022-06-01 01:17:35', 0, 1, 1), (43, 37, 3, 1, '2022-05-31 12:58:18', 'Jun', '2023', '2022-05-31 12:58:18', '2022-06-01 01:12:40', 0, 1, 1), (44, 49, 1, 1, '2022-05-31 12:58:32', 'May', '2022', '2022-05-31 12:58:32', '2022-05-31 12:58:32', 0, 1, 2), (45, 49, 2, 1, '2022-05-31 12:58:40', 'May', '2022', '2022-05-31 12:58:40', '2022-05-31 12:58:40', 0, 1, 1), (47, 49, 1, 1, '2022-05-31 12:59:01', 'Jun', '2022', '2022-05-31 12:59:01', '0000-00-00 00:00:00', 0, 1, 2), (48, 49, 2, 1, '2022-05-31 12:59:14', 'Jun', '2022', '2022-05-31 12:59:14', '2022-06-01 01:12:40', 0, 1, 1), (49, 49, 3, 1, '2022-05-31 12:59:31', 'Jun', '2022', '2022-05-31 12:59:31', '2022-06-01 01:12:40', 0, 1, 1), (50, 49, 1, 1, '2022-05-31 12:59:41', 'May', '2023', '2022-05-31 12:59:41', '2022-05-31 12:59:41', 0, 1, 2), (51, 49, 2, 1, '2022-05-31 12:59:49', 'May', '2023', '2022-05-31 12:59:49', '2022-05-31 12:59:49', 0, 1, 1), (52, 49, 3, 1, '2022-05-31 13:00:05', 'May', '2023', '2022-05-31 13:00:05', '2022-05-31 13:00:05', 0, 1, 1), (53, 49, 1, 1, '2022-05-31 13:00:21', 'Jun', '2023', '2022-05-31 13:00:21', '2022-06-01 01:12:40', 0, 1, 2), (54, 49, 2, 1, '2022-05-31 13:00:32', 'Jun', '2023', '2022-05-31 13:00:32', '2022-06-01 01:12:40', 0, 1, 1), (55, 49, 3, 1, '2022-05-31 13:00:43', 'Jun', '2023', '2022-05-31 13:00:43', '2022-06-01 01:12:40', 0, 1, 1), (56, 88, 1, 1, '2022-05-31 13:01:25', 'May', '2022', '2022-05-31 13:01:25', '2022-05-31 13:01:25', 0, 1, 2), (57, 88, 2, 1, '2022-05-31 13:01:30', 'May', '2022', '2022-05-31 13:01:30', '2022-05-31 13:01:30', 0, 1, 1), (58, 88, 3, 1, '2022-05-31 13:01:37', 'May', '2022', '2022-05-31 13:01:37', '2022-05-31 13:01:37', 0, 1, 1), (59, 88, 1, 1, '2022-05-31 13:01:45', 'Jun', '2022', '2022-05-31 13:01:45', '2022-06-01 01:27:00', 0, 1, 2), (60, 88, 2, 1, '2022-05-31 13:01:52', 'Jun', '2022', '2022-05-31 13:01:52', '2022-06-01 01:12:40', 0, 1, 1), (62, 88, 1, 1, '2022-05-31 13:02:37', 'Jun', '2023', '2022-05-31 13:02:37', '2022-06-01 01:27:07', 0, 1, 2), (63, 88, 2, 1, '2022-05-31 13:02:54', 'Jun', '2023', '2022-05-31 13:02:54', '2022-06-01 01:12:40', 0, 1, 1), (64, 88, 3, 1, '2022-05-31 13:03:04', 'Jun', '2023', '2022-05-31 13:03:04', '2022-06-01 01:27:10', 0, 1, 1), (65, 88, 1, 1, '2022-05-31 13:03:14', 'May', '2023', '2022-05-31 13:03:14', '2022-05-31 13:03:14', 0, 1, 2), (66, 88, 2, 1, '2022-05-31 13:03:22', 'May', '2023', '2022-05-31 13:03:22', '2022-05-31 13:03:22', 0, 1, 1), (67, 88, 3, 1, '2022-05-31 13:03:31', 'May', '2023', '2022-05-31 13:03:31', '2022-05-31 13:03:31', 0, 1, 1), (68, 89, 1, 1, '2022-05-31 13:04:21', 'May', '2022', '2022-05-31 13:04:21', '2022-05-31 13:04:21', 0, 1, 2), (69, 89, 2, 1, '2022-05-31 13:04:34', 'May', '2022', '2022-05-31 13:04:34', '2022-05-31 13:04:34', 0, 1, 1), (70, 89, 3, 1, '2022-05-31 13:04:40', 'May', '2022', '2022-05-31 13:04:40', '2022-05-31 13:04:40', 0, 1, 1), (71, 89, 1, 1, '2022-05-31 13:04:49', 'Jun', '2022', '2022-05-31 13:04:49', '2022-06-01 01:12:40', 0, 1, 2), (72, 89, 2, 1, '2022-05-31 13:04:56', 'Jun', '2022', '2022-05-31 13:04:56', '2022-06-01 01:12:40', 0, 1, 1), (73, 89, 3, 1, '2022-05-31 13:05:14', 'Jun', '2022', '2022-05-31 13:05:14', '2022-06-01 01:10:41', 0, 1, 1), (74, 89, 1, 1, '2022-05-31 13:05:24', 'May', '2023', '2022-05-31 13:05:24', '2022-05-31 13:05:24', 0, 1, 2), (75, 89, 2, 1, '2022-05-31 13:05:31', 'May', '2023', '2022-05-31 13:05:31', '2022-05-31 13:05:31', 0, 1, 1), (76, 89, 3, 1, '2022-05-31 13:05:41', 'May', '2023', '2022-05-31 13:05:41', '2022-05-31 13:05:41', 0, 1, 1), (77, 89, 1, 1, '2022-05-31 13:05:51', 'Jun', '2023', '2022-05-31 13:05:51', '2022-06-01 01:12:40', 0, 1, 2), (78, 89, 2, 1, '2022-05-31 13:05:59', 'Jun', '2023', '2022-05-31 13:05:59', '0000-00-00 00:00:00', 0, 1, 1), (79, 89, 3, 1, '2022-05-31 13:06:09', 'Jun', '2023', '2022-05-31 13:06:09', '2022-06-01 01:27:12', 0, 1, 1), (80, 84, 1, 1, '2022-05-31 13:07:19', 'May', '2022', '2022-05-31 13:07:19', '2022-06-01 03:40:25', 0, 1, 2), (81, 84, 2, 1, '2022-05-31 13:07:24', 'May', '2022', '2022-05-31 13:07:24', '2022-05-31 13:07:24', 0, 1, 1), (82, 84, 3, 1, '2022-05-31 13:07:31', 'May', '2022', '2022-05-31 13:07:31', '2022-06-01 03:42:52', 0, 1, 1), (83, 84, 1, 1, '2022-05-31 13:07:38', 'Jun', '2022', '2022-05-31 13:07:38', '2022-06-01 01:12:40', 0, 1, 2), (84, 84, 2, 1, '2022-05-31 13:07:45', 'Jun', '2022', '2022-05-31 13:07:45', '2022-06-01 01:27:14', 0, 1, 1), (85, 84, 3, 1, '2022-05-31 13:07:53', 'Jun', '2022', '2022-05-31 13:07:53', '2022-06-01 01:27:16', 0, 1, 1), (86, 84, 1, 1, '2022-05-31 13:08:12', 'May', '2023', '2022-05-31 13:08:12', '2022-05-31 13:08:12', 0, 1, 2), (87, 84, 2, 1, '2022-05-31 13:08:23', 'May', '2023', '2022-05-31 13:08:23', '2022-05-31 13:08:23', 0, 1, 1), (88, 84, 3, 1, '2022-05-31 13:08:30', 'May', '2023', '2022-05-31 13:08:30', '2022-05-31 13:08:30', 0, 1, 1), (89, 84, 1, 1, '2022-05-31 13:08:44', 'Jun', '2023', '2022-05-31 13:08:44', '2022-06-01 01:27:20', 0, 1, 2), (90, 84, 2, 1, '2022-05-31 13:08:58', 'Jun', '2023', '2022-05-31 13:08:58', '2022-06-01 01:27:22', 0, 1, 1), (91, 84, 3, 1, '2022-05-31 13:09:06', 'Jun', '2023', '2022-05-31 13:09:06', '2022-06-01 01:27:26', 0, 1, 1), (92, 121, 1, 1, '2022-05-31 13:09:59', 'May', '2022', '2022-05-31 13:09:59', '2022-05-31 13:09:59', 0, 1, 2), (93, 121, 2, 1, '2022-05-31 13:10:06', 'May', '2022', '2022-05-31 13:10:06', '2022-05-31 13:10:06', 0, 1, 1), (94, 121, 3, 1, '2022-05-31 13:10:13', 'May', '2022', '2022-05-31 13:10:13', '2022-05-31 13:10:13', 0, 1, 1), (95, 121, 1, 1, '2022-05-31 13:10:20', 'Jun', '2022', '2022-05-31 13:10:20', '2022-06-01 01:27:27', 0, 1, 2), (96, 121, 2, 1, '2022-05-31 13:10:29', 'Jun', '2022', '2022-05-31 13:10:29', '2022-06-01 01:27:29', 0, 1, 1), (97, 121, 3, 1, '2022-05-31 13:10:38', 'Jun', '2022', '2022-05-31 13:10:38', '2022-06-01 01:27:30', 0, 1, 1), (98, 121, 1, 1, '2022-05-31 13:10:50', 'May', '2023', '2022-05-31 13:10:50', '2022-05-31 13:10:50', 0, 1, 2), (99, 121, 2, 1, '2022-05-31 13:10:57', 'May', '2023', '2022-05-31 13:10:57', '2022-05-31 13:10:57', 0, 1, 1), (100, 121, 3, 1, '2022-05-31 13:11:11', 'May', '2023', '2022-05-31 13:11:11', '2022-05-31 13:11:11', 0, 1, 1), (101, 107, 1, 1, '2022-05-31 13:11:34', 'May', '2022', '2022-05-31 13:11:34', '2022-05-31 13:11:34', 0, 1, 2), (102, 107, 2, 1, '2022-05-31 13:11:39', 'May', '2022', '2022-05-31 13:11:39', '2022-05-31 13:11:39', 0, 1, 1), (103, 107, 3, 1, '2022-05-31 13:11:44', 'May', '2022', '2022-05-31 13:11:44', '2022-05-31 13:11:44', 0, 1, 1), (104, 107, 1, 1, '2022-05-31 13:11:51', 'Jun', '2022', '2022-05-31 13:11:51', '2022-06-01 01:10:41', 0, 1, 2), (105, 107, 2, 1, '2022-05-31 13:12:05', 'Jun', '2022', '2022-05-31 13:12:05', '2022-06-01 01:27:32', 0, 1, 1), (106, 107, 3, 1, '2022-05-31 13:12:14', 'Jun', '2022', '2022-05-31 13:12:14', '2022-06-01 07:57:46', 0, 1, 1), (107, 107, 1, 1, '2022-05-31 13:12:28', 'May', '2023', '2022-05-31 13:12:28', '2022-05-31 13:12:28', 0, 1, 2), (108, 107, 2, 1, '2022-05-31 13:12:37', 'May', '2023', '2022-05-31 13:12:37', '2022-05-31 13:12:37', 0, 1, 1), (109, 107, 3, 1, '2022-05-31 13:12:45', 'May', '2023', '2022-05-31 13:12:45', '2022-05-31 13:12:45', 0, 1, 1), (110, 107, 1, 1, '2022-05-31 13:12:56', 'Jun', '2023', '2022-05-31 13:12:56', '2022-06-01 01:27:36', 0, 1, 2), (111, 107, 2, 1, '2022-05-31 13:13:05', 'Jun', '2023', '2022-05-31 13:13:05', '2022-06-01 01:27:38', 0, 1, 1), (112, 107, 3, 1, '2022-05-31 13:17:28', 'Jun', '2023', '2022-05-31 13:17:28', '2022-06-01 01:27:40', 0, 1, 1), (113, 113, 1, 1, '2022-05-31 13:18:57', 'May', '2022', '2022-05-31 13:18:57', '2022-05-31 13:18:57', 0, 1, 1), (114, 113, 2, 1, '2022-05-31 13:19:04', 'May', '2022', '2022-05-31 13:19:04', '2022-05-31 13:19:04', 0, 1, 1), (115, 113, 3, 1, '2022-05-31 13:19:10', 'May', '2022', '2022-05-31 13:19:10', '2022-05-31 13:19:10', 0, 1, 1), (116, 113, 1, 1, '2022-05-31 13:19:18', 'Jun', '2022', '2022-05-31 13:19:18', '2022-06-01 01:10:41', 0, 1, 1), (117, 113, 2, 1, '2022-05-31 13:19:24', 'Jun', '2022', '2022-05-31 13:19:24', '2022-06-01 01:27:41', 0, 1, 1), (118, 113, 3, 1, '2022-05-31 13:19:31', 'Jun', '2022', '2022-05-31 13:19:31', '2022-06-01 07:57:43', 0, 1, 1), (119, 113, 1, 1, '2022-05-31 13:19:41', 'May', '2023', '2022-05-31 13:19:41', '2022-05-31 13:19:41', 0, 1, 1), (120, 113, 2, 1, '2022-05-31 13:19:48', 'May', '2023', '2022-05-31 13:19:48', '2022-05-31 13:19:48', 0, 1, 1), (121, 113, 3, 1, '2022-05-31 13:19:54', 'May', '2023', '2022-05-31 13:19:54', '2022-05-31 13:19:54', 0, 1, 1), (122, 113, 1, 1, '2022-05-31 13:20:04', 'Jun', '2023', '2022-05-31 13:20:04', '2022-06-01 01:27:45', 0, 1, 1), (123, 113, 2, 1, '2022-05-31 13:20:13', 'Jun', '2023', '2022-05-31 13:20:13', '2022-06-01 01:27:49', 0, 1, 1), (124, 113, 3, 1, '2022-05-31 13:20:22', 'Jun', '2023', '2022-05-31 13:20:22', '2022-06-01 01:27:53', 0, 1, 1), (125, 119, 1, 1, '2022-05-31 13:21:12', 'May', '2022', '2022-05-31 13:21:12', '2022-05-31 13:21:12', 0, 1, 1), (126, 119, 2, 1, '2022-05-31 13:21:18', 'May', '2022', '2022-05-31 13:21:18', '2022-05-31 13:21:18', 0, 1, 1), (127, 119, 3, 1, '2022-05-31 13:21:29', 'May', '2022', '2022-05-31 13:21:29', '2022-05-31 13:21:29', 0, 1, 1), (128, 119, 1, 1, '2022-05-31 13:21:45', 'Jun', '2022', '2022-05-31 13:21:45', '2022-06-01 01:27:54', 0, 1, 1), (129, 119, 2, 1, '2022-05-31 13:21:53', 'Jun', '2022', '2022-05-31 13:21:53', '2022-06-01 01:27:56', 0, 1, 1), (130, 119, 3, 1, '2022-05-31 13:22:16', 'Jun', '2022', '2022-05-31 13:22:16', '2022-06-01 01:28:00', 0, 1, 1), (131, 119, 1, 1, '2022-05-31 13:22:24', 'May', '2023', '2022-05-31 13:22:24', '2022-05-31 13:22:24', 0, 1, 1), (132, 119, 2, 1, '2022-05-31 13:22:30', 'May', '2023', '2022-05-31 13:22:30', '2022-05-31 13:22:30', 0, 1, 1), (133, 119, 3, 1, '2022-05-31 13:22:36', 'May', '2023', '2022-05-31 13:22:36', '2022-05-31 13:22:36', 0, 1, 1), (134, 119, 1, 1, '2022-05-31 13:22:45', 'Jun', '2023', '2022-05-31 13:22:45', '2022-06-01 01:28:03', 0, 1, 1), (135, 119, 2, 1, '2022-05-31 13:22:53', 'Jun', '2023', '2022-05-31 13:22:53', '2022-06-01 01:28:04', 0, 1, 1), (136, 119, 3, 1, '2022-05-31 13:23:10', 'Jun', '2023', '2022-05-31 13:23:10', '2022-06-01 01:28:08', 0, 1, 1), (137, 13, 1, 1, '2022-05-31 13:40:26', 'May', '2022', '2022-05-31 13:40:26', '2022-05-31 13:40:26', 0, 1, 1), (138, 13, 2, 1, '2022-05-31 13:40:31', 'May', '2022', '2022-05-31 13:40:31', '2022-05-31 13:40:31', 0, 1, 1), (139, 13, 3, 1, '2022-05-31 13:40:36', 'May', '2022', '2022-05-31 13:40:36', '2022-05-31 13:40:36', 0, 1, 1), (140, 13, 1, 1, '2022-05-31 13:40:42', 'Jun', '2022', '2022-05-31 13:40:42', '2022-06-01 01:28:10', 0, 1, 1), (141, 13, 2, 1, '2022-05-31 13:40:53', 'Jun', '2022', '2022-05-31 13:40:53', '2022-06-01 01:28:11', 0, 1, 1), (142, 13, 3, 1, '2022-05-31 13:41:11', 'Jun', '2022', '2022-05-31 13:41:11', '2022-06-01 03:41:46', 0, 1, 1); -- -- Indexes for dumped tables -- -- -- Indexes for table `attendance` -- ALTER TABLE `attendance` ADD PRIMARY KEY (`atid`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `attendance` -- ALTER TABLE `attendance` MODIFY `atid` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=143; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; I followed this code below and it has different results and can't really do it myself, <?php if(isset($_POST['search'])) { $search = $_POST['search'] ?? ''; $year = $_POST['year'] ?? ''; $month = $_POST['month'] ?? ''; $sql = "SELECT DISTINCT entrydate FROM attendance ORDER BY entrydate "; $res = $link->query($sql); // mysqli query while ($row = $res->fetch_row()) { $dates[] = $row[0]; } /*********************************** * Table headings * ************************************/ $emptyRow = array_fill_keys($dates,''); // format dates foreach ($dates as $k=>$v) { $dates[$k] = date('d-M', strtotime($v)); } $heads = "<table class='table table-stripped table-bordered'>\n"; $heads .= "<tr><th>Name</th><th>" . join('</th><th>', $dates) . "</th></tr>\n"; /*********************************** * Main data * ************************************/ $sql = "SELECT entrydate, memid, astatus FROM attendance ORDER BY memid"; $res = $link->query($sql); $curname=''; $tdata = ''; while (list($d, $sn, $s) = $res->fetch_row()) { if ($curname != $sn) { if ($curname) { $tdata .= "<tr><td>$curname</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n"; } $rowdata = $emptyRow; $curname = $sn; } $rowdata[$d] = $s; } $tdata .= "<tr><td>$curname</td><td>" . join('</td><td>', $rowdata). "</td></tr>\n"; $tdata .= "</table\n"; } ?> <?php echo $heads; echo $tdata; ?> Notes: memid = Member name serid = Services like (PM, PBB, WS) calid = 1st Week, 2nd Week and so-on. entrydate = TimeIn date. Hoping that there are someone who's able to help a newbie like me. Thank you and appreciate that.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.