php - how to get data weekly. Only till Monday to Next Sunday -
i have coded program in can data of last 7 days. want data should visible of last week , week starts monday , ends @ sunday. on monday next week starts. want if today wednesday , if click on week report. should data till last monday . (wednesday, tuesday, monday) system counts complete 7 days. here codes.
date_default_timezone_set("est"); $wdate = date('y-m-d'); $wdate_to = $wdate; $wdate_to = strtotime("-7 days", strtotime($wdate_to)); //-7 days last week. -30 last week $wdate_to = date("y-m-d", $wdate_to); $wget_req = "select * `requests` `assign_date` between '$wdate_to' , '$wdate' , `assigned`=1"; $result = mysqli_query($dbc, $wget_req); while ($res = mysqli_fetch_assoc($result)){ $driver_id = $res['assigned_driver_id']; $req_id = $res['req_id']; $req_title = $res['request_title']; $req_price = $res['price']; $req_time = $res['request_time']; $req_date = $res['assign_date']; $req_desc = $res['req_desc']; $assigned = $res['assigned']; $status = $res['req_status']; $driver = $res['driver_name']; $get_record = "select * `members` `memberid`='$driver_id' , `u_level`=3"; $res = mysqli_query($dbc, $get_record); while($row = mysqli_fetch_assoc($res)){ $status = $row['u_status']; } ?> <tr class="gradea"> <td><b><?php echo $driver ;?></b></td> <td><?php echo $driver_id ;?></td> <td><?php echo $req_date ;?></td> <td><b><?php echo $wdate_to;?></b> ↔ <b><?php echo $wdate ;?></b></td> <td class="center"><?php if($status == 1){echo '<a href="#" class="btn btn-danger btn-sm">driver not working. deactivated</a>';}else if($status == 0){echo '<a href="#" class="btn btn-success btn-sm">driver active. working</a>';}?></td> <td class="center"> <a href="weekly_report.php?driver_id=<?php echo $driver_id ;?>" class="btn btn-primary btn-sm">view report</a> </td> </tr> <?php } ?>
i hope soon
try this, may you
<?php date_default_timezone_set("est"); $wdate = date('y-m-d',strtotime('monday week')); $wdate_to = $wdate; $wdate_to = strtotime("-7 days", strtotime($wdate_to)); //-7 days last week. -30 last week $wdate_to = date("y-m-d", $wdate_to); $wget_req = "select * `requests` `assign_date` between '$wdate_to' , '$wdate' , `assigned`=1"; $result = mysqli_query($dbc, $wget_req); while ($res = mysqli_fetch_assoc($result)){ $driver_id = $res['assigned_driver_id']; $req_id = $res['req_id']; $req_title = $res['request_title']; $req_price = $res['price']; $req_time = $res['request_time']; $req_date = $res['assign_date']; $req_desc = $res['req_desc']; $assigned = $res['assigned']; $status = $res['req_status']; $driver = $res['driver_name']; $get_record = "select * `members` `memberid`='$driver_id' , `u_level`=3"; $res = mysqli_query($dbc, $get_record); while($row = mysqli_fetch_assoc($res)){ $status = $row['u_status']; } ?> <tr class="gradea"> <td><b><?php echo $driver ;?></b></td> <td><?php echo $driver_id ;?></td> <td><?php echo $req_date ;?></td> <td><b><?php echo $wdate_to;?></b> ↔ <b><?php echo $wdate ;?></b></td> <td class="center"><?php if($status == 1){echo '<a href="#" class="btn btn-danger btn-sm">driver not working. deactivated</a>';}else if($status == 0){echo '<a href="#" class="btn btn-success btn-sm">driver active. working</a>';}?></td> <td class="center"> <a href="weekly_report.php?driver_id=<?php echo $driver_id ;?>" class="btn btn-primary btn-sm">view report</a> </td> </tr> <?php } ?>
Comments
Post a Comment