table receipt
coupondate receipt
02-05-2015 5
02-09-2015 5
i am selecting min coupondate and max coupondate from table...
below is my query..
SELECT RE.*,min(RE.coupondate) As mindate,max(RE.coupondate) As Maxdate FROM receipt_entry RE GROUP BY RE.receipt_no
Next i used fromdate and todate textbox in my form.
if user enter fromdate = 01-05-2015 and todate = 31-05-2015..then i am display all days between this two dates like below example....
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 ......upto ....31
i used below code to display all days between two date...
<?php
$startdate = $_POST['fromdate'];
$enddate = $_POST['todate'];
$start = date('d', strtotime($startdate));
$end=date('d', strtotime($enddate));
?>
<?php for ($x = $start; $x <= $end; $x++) {?>
<th width="58%"><?php echo $x; ?></th>
<?php } ?>
Now what i need is ...
I need to print 1 starts from $row(mindate) and print continously upto last day.that is 31
Expected output is
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 ....31
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
i try below code to print 1 which starts from mindate and end on 31.
but my code only display 1 below mindate..thats it...
<?php if (is_array($data)) { foreach($data as $row) { ?>
<tbody>
<tr>
<td><?php echo htmlspecialchars($row['customer_name']); ?></td>
<td><?php echo htmlspecialchars($row['startingdate']); ?></td>
<td><?php echo htmlspecialchars($row['coupondate']); ?></td>
<?php for ($x = $start; $x <= $end; $x++) { ?>
<?php if($row['mindate']== $x) { ?>
<td>1</td>
<?php } else {?>
<td>-</td>
<?php } ?>
<?php } ?>
</tr>
<?php } }?>
I am getting below output..
01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 ....31
- 1 - - - - - - - - - - - - - - - - - - - - -