phpbigenner Posted August 7, 2013 Share Posted August 7, 2013 (edited) i have a database name movie and the fields are "datestart ", "dateended ". my problem is i want to retrieve the date that the movie is STARTED until the date that the movie is ENDED. example; date started is august 8, 2013, and the date ended is august 14, 2013 may concern is how to retrieve the date august 9, 2013, august 10, 2013 until august 13, 2013 // this is my code <?php $q = mysql_query("select * from movie "); $row = mysql_fetch_array($q); $sdate=$row['datestart']; $edate=$row['dateended']; while($sdate<=$edate){ echo "<option value=$sdate>$sdate</datestart>"; $sdate=mktime(0,0,0,date("m"),(date("d")+1),date("Y")); } ?> Edited August 7, 2013 by phpbigenner Quote Link to comment Share on other sites More sharing options...
requinix Posted August 7, 2013 Share Posted August 7, 2013 Assuming datestart and dateended are integers (not date/time strings) then you're close, you just have to fix the $sdate=mktime(0,0,0,date("m"),(date("d")+1),date("Y"));so that it doesn't go according to today's date but instead adds one day to $sdate. Like $sdate = strtotime("+1 day", $sdate);But there might be another problem. datestart and dateended: they really are integers, right? They have precision to the second so how are you dealing with the fact that you only care about the date portion? Do they correspond to midnight on their respective days? Quote Link to comment Share on other sites More sharing options...
phpbigenner Posted August 8, 2013 Author Share Posted August 8, 2013 datestart and dateended are strings not integers. Quote Link to comment Share on other sites More sharing options...
phpbigenner Posted August 8, 2013 Author Share Posted August 8, 2013 thanks bro. I fix my problem. // this is my code now // datestart and dateended are strings <?php $q = mysql_query("select * from movie "); $row = mysql_fetch_array($q); $sdate=$row['datestart']; $edate=$row['dateended']; while($sdate<=$edate) { echo "<option value=$sdate>$sdate</$sdate>"; $sdate =date('m/d/Y', strtotime('+1 day', strtotime($sdate))); } ?> Quote Link to comment Share on other sites More sharing options...
phpbigenner Posted August 12, 2013 Author Share Posted August 12, 2013 hey guy's! I have a problem again on how to trap the time. example if the datestart is 08/12/2013 and the date dateended is 08/12/2013. what should i do to display the dateended until it will greater than 12 AM in the midnight. // this is my code now // datestart and dateended are strings <?php $q = mysql_query("select * from movie "); $row = mysql_fetch_array($q); $sdate=$row['datestart']; $edate=$row['dateended']; while($sdate<=$edate) { echo "<option value=$sdate>$sdate</$sdate>"; $sdate =date('m/d/Y', strtotime('+1 day', strtotime($sdate))); } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.