我每次需要使用while循环在PHP的Bootstrap轮播中显示3个日期项,我想在一张幻灯片中显示3个日期项,下一张幻灯片中还有3个数据项,依此类推。
这是我尝试过的:
<?php
date_default_timezone_set('UTC');
$date = date('Y-m-d');
$end_date = '2018-11-05'; ?>
<div role="listbox" class="carousel-inner" >
<?php $i_count = 1; ?>
<?php if($i_count==1){ ?>
<div class="item active">
<?php }
else if($i_count%3==0) { ?>
<div class="item">
<?php } ?>
<div class="col-md-12 pa-0">
<?php
while(strtotime($date) <= strtotime($end_date))
{
$date = date ("Y-m-d", strtotime("+1 day", strtotime($date)));
?>
<div class="col-md-4 col-sm-4 col-xs-4 pa-0 <?php if ($i_count == 1 || $i_count == 2 || $i_count == 3 ) echo ' activeday'?>">
<div class="date-heading">
<div class="day-of-week"><?= date('l', strtotime($date)); ?></div>
<div class="date-secondary pb-5"><?= date('F d', strtotime($date)); ?></div>
<div class="date-head-text"><?= date('l', strtotime($date)); ?></div>
</div>
<div class="choose-time">
<div class="form-inline">
<input class="time-selection" name="time[]" data-readable-date="2018-02-03" value="2018-02-03 06:15" id="appt1517638500" data-original-text="2018-02-03 06:15" type="radio">
<label id="lbl_appt1517638500" for="appt1517638500" data-original-text="11:45">11:45</label><br>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
<?php $i_count++; ?>
</div>
<a href="#carousel-example-captions" role="button" data-slide="prev" class="left carousel-control">
<span aria-hidden="true" class="fa fa-caret-left"></span>
<span class="sr-only">Previous</span>
</a>
<a href="#carousel-example-captions" role="button" data-slide="next" class="right carousel-control" >
<span aria-hidden="true" class="fa fa-caret-right"></span>
<span class="sr-only">Next</span>
</a>
</div>