Как получить предыдущий день (непрерывный)

Привет, ребята, я хочу получить информацию о предыдущей дате или в последний день, только когда я нажму кнопку, и она отобразит всю информацию в последний день (субботу), и если я снова нажму кнопку, она отобразит информацию последнего последнего дня (пятница) и если я нажму на него снова (в четверг), спасибо за помощь мне, ребята

Редакция:

generate_attendance.php

if(isset($_POST['submit1'])){ $prev_date= date('Y/m/d',strtotime("-1 days")); $query=mysqli_query($dbcon,"select * from attendance where date_added '$prev_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?</td> </tr> <?php <div class="controls"> <button name="submit1" type="submit1" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Previous Day</button> </div> </div> 

generate_attendance.php (полный код)

 <div class="container"> <div class="margin-top"> <div class="row"> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">&times;</button> <strong><i class="icon-user icon-large"></i>&nbsp;Attendance Report</strong> </div> <div class="span12"> <center class="title"> <h1>Attendance List</h1> </center> <div class="pull-right"> <a href="" onclick="window.print()" class="btn btn-info"><i class="icon-print icon-large"></i> Print</a> </div> <form method="post"> <div class="span3"> <div class="control-group"> <label class="control-label" for="inputEmail"><!-- Attendance Report --></label> <div class="controls"> <label class="control-label" for="inputEmail">From</label> <div class="controls"> <input type="date" name="from_date" id="date1" alt="date" class="IP_calendar" title="d/m/Y"> </div> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">To Date</label> <div class="controls"> <input type="date" name="to_date" id="date2" alt="date" class="IP_calendar" title="d/m/Y"> <!-- <input type="text" class="w8em format-dmy highlight-days-67 range-low-today" name="due_date" id="sd" maxlength="10" style="border: 3px double #CCCCCC;" required/> --> </div> </div> <div class="control-group"> <div class="controls"> <button name="submit" type="submit" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Search</button> </div> </div> <div class="controls"> <button name="submit1" type="submit1" class="btn btn-success"><i class="icon-minus-sign icon-large"></i> Previous Day</button> </div> </div> <div class="span8"> <div class="alert alert-success"><strong>Attendance Report</strong></div> <table cellpadding="0" cellspacing="0" border="0" class="table" id="example"> <thead> <tr> <th>Name</th> <th>Program Code</th> <th>Type</th> <th>Year level</th> <th>Date Log-in</th> </tr> </thead> <tbody> <?php if(isset($_POST['submit'])){ $from_date=$_POST['from_date']; $to_date=$_POST['to_date']; $query=mysqli_query($dbcon,"select * from attendance where date_added between '$from_date' and '$to_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> <?php if(isset($_POST['submit1'])){ $prev_date= date('Y/m/d',strtotime("-1 days")); $query=mysqli_query($dbcon,"select * from attendance where date_added between '$curr_date' and '$prev_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> </tbody> </table> </form> </div> </div> </div> </div> </div> в <div class="container"> <div class="margin-top"> <div class="row"> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">&times;</button> <strong><i class="icon-user icon-large"></i>&nbsp;Attendance Report</strong> </div> <div class="span12"> <center class="title"> <h1>Attendance List</h1> </center> <div class="pull-right"> <a href="" onclick="window.print()" class="btn btn-info"><i class="icon-print icon-large"></i> Print</a> </div> <form method="post"> <div class="span3"> <div class="control-group"> <label class="control-label" for="inputEmail"><!-- Attendance Report --></label> <div class="controls"> <label class="control-label" for="inputEmail">From</label> <div class="controls"> <input type="date" name="from_date" id="date1" alt="date" class="IP_calendar" title="d/m/Y"> </div> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">To Date</label> <div class="controls"> <input type="date" name="to_date" id="date2" alt="date" class="IP_calendar" title="d/m/Y"> <!-- <input type="text" class="w8em format-dmy highlight-days-67 range-low-today" name="due_date" id="sd" maxlength="10" style="border: 3px double #CCCCCC;" required/> --> </div> </div> <div class="control-group"> <div class="controls"> <button name="submit" type="submit" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Search</button> </div> </div> <div class="controls"> <button name="submit1" type="submit1" class="btn btn-success"><i class="icon-minus-sign icon-large"></i> Previous Day</button> </div> </div> <div class="span8"> <div class="alert alert-success"><strong>Attendance Report</strong></div> <table cellpadding="0" cellspacing="0" border="0" class="table" id="example"> <thead> <tr> <th>Name</th> <th>Program Code</th> <th>Type</th> <th>Year level</th> <th>Date Log-in</th> </tr> </thead> <tbody> <?php if(isset($_POST['submit'])){ $from_date=$_POST['from_date']; $to_date=$_POST['to_date']; $query=mysqli_query($dbcon,"select * from attendance where date_added between '$from_date' and '$to_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> <?php if(isset($_POST['submit1'])){ $prev_date= date('Y/m/d',strtotime("-1 days")); $query=mysqli_query($dbcon,"select * from attendance where date_added between '$curr_date' and '$prev_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> </tbody> </table> </form> </div> </div> </div> </div> </div> в <div class="container"> <div class="margin-top"> <div class="row"> <div class="alert alert-info"> <button type="button" class="close" data-dismiss="alert">&times;</button> <strong><i class="icon-user icon-large"></i>&nbsp;Attendance Report</strong> </div> <div class="span12"> <center class="title"> <h1>Attendance List</h1> </center> <div class="pull-right"> <a href="" onclick="window.print()" class="btn btn-info"><i class="icon-print icon-large"></i> Print</a> </div> <form method="post"> <div class="span3"> <div class="control-group"> <label class="control-label" for="inputEmail"><!-- Attendance Report --></label> <div class="controls"> <label class="control-label" for="inputEmail">From</label> <div class="controls"> <input type="date" name="from_date" id="date1" alt="date" class="IP_calendar" title="d/m/Y"> </div> </div> </div> <div class="control-group"> <label class="control-label" for="inputEmail">To Date</label> <div class="controls"> <input type="date" name="to_date" id="date2" alt="date" class="IP_calendar" title="d/m/Y"> <!-- <input type="text" class="w8em format-dmy highlight-days-67 range-low-today" name="due_date" id="sd" maxlength="10" style="border: 3px double #CCCCCC;" required/> --> </div> </div> <div class="control-group"> <div class="controls"> <button name="submit" type="submit" class="btn btn-success"><i class="icon-plus-sign icon-large"></i> Search</button> </div> </div> <div class="controls"> <button name="submit1" type="submit1" class="btn btn-success"><i class="icon-minus-sign icon-large"></i> Previous Day</button> </div> </div> <div class="span8"> <div class="alert alert-success"><strong>Attendance Report</strong></div> <table cellpadding="0" cellspacing="0" border="0" class="table" id="example"> <thead> <tr> <th>Name</th> <th>Program Code</th> <th>Type</th> <th>Year level</th> <th>Date Log-in</th> </tr> </thead> <tbody> <?php if(isset($_POST['submit'])){ $from_date=$_POST['from_date']; $to_date=$_POST['to_date']; $query=mysqli_query($dbcon,"select * from attendance where date_added between '$from_date' and '$to_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> <?php if(isset($_POST['submit1'])){ $prev_date= date('Y/m/d',strtotime("-1 days")); $query=mysqli_query($dbcon,"select * from attendance where date_added between '$curr_date' and '$prev_date'")or die(mysql_error()); while($row=mysqli_fetch_array($query)){ $attendance_id=$row['attendance_id']; ?> <tr> <td><?php echo $row['lastname'].', '.$row['firstname']; ?></td> <td><?php echo $row['course']; ?></td> <td><?php echo $row['type']; ?></td> <td><?php echo $row['year_level']; ?></td> <td><?php echo $row['date_added']; ?></td> </tr> <?php }} ?> </tbody> </table> </form> </div> </div> </div> </div> </div>