Hi, Yesterday I try to figure out that if we input day and the system will add day to current date and display result but I got problem example below
input 1 day to add
table
1st record 2012-05-05 Add 1 day 2012-05-06
input another 3 day
table
1st record 2012-05-05 Add 1 day 2012-05-06
2st record 2012-05-05 Add 3 day 2012-05-08
The problem is 2nd need to start from 2012-05-06 not current date here code part of my big system
It should be like
input 3 day 2st record 2012-05-06 Add 3 day 2012-05-09
input 4 day 3nd record 2012-05-09 Add 3 day 2012-05-12
THank
if ($_REQUEST[roomrent_id] == '') {
$sql_roomrent = "SELECT * FROM `roomrent` WHERE `guest_id`=(SELECT `id` FROM `guests` WHERE `room_id`='$_REQUEST[id]' AND `checkout_datetime`='0000-00-00 00:00:00') ORDER BY `id` DESC";
} else {
$sql_roomrent = "SELECT * FROM `roomrent` WHERE `guest_id`=(SELECT `id` FROM `guests` WHERE `room_id`='$_REQUEST[id]' AND `checkout_datetime`='0000-00-00 00:00:00') AND `id`='$_REQUEST[roomrent_id]' ORDER BY `id` DESC";
}
$q_roomrent = mysql_query($sql_roomrent);
while ($row_roomrent = mysql_fetch_assoc($q_roomrent)) {
$day_paid = $row_roomrent['day_pay']; // This what I called day input from DB
$date_4 = $row_roomrent['start_datetime']; //called the date that checkin
$stop_date = date("Y-m-d", strtotime($date_4. '+'. $day_paid.'day')); // added together
mysql_query("UPDATE `roomrent` SET `date`='$stop_date' WHERE `guest_id`=(SELECT `id` FROM `guests` WHERE `room_id`='$_REQUEST[id]' AND `checkout_datetime`='0000-00-00 00:00:00') AND `id`= $roomrent_id "); // store back to other field
<td><font color="#<?= $font_color ?>"><?= $date_4 ?></font></td>
<td><font color="#<?= $font_color ?>"><?= $days_total ?> <?= DAYT ?></fo;nt></td>
<td><font color="#<?= $font_color ?>"><?= $day_paid ?> <?= DAYT ?></font></td>
<td><font color="#<?= $font_color ?>"><?= $stop_date ?> </font></td>