jakebur01 Posted September 5, 2008 Share Posted September 5, 2008 I have a table full of events. Each event has a timestamp date on the same row. I am wanting to pull only the events that are scheduled for today and sort them. I also want on another page to pull all of the events for the month and sort them. Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/ Share on other sites More sharing options...
severndigital Posted September 5, 2008 Share Posted September 5, 2008 these are simple, but we need more info. 1. where / how are the entries stored? 2. how are the dates formatted? Thanks, C Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634518 Share on other sites More sharing options...
revraz Posted September 5, 2008 Share Posted September 5, 2008 Just do a sql query that selects the rows that are for the current date and use a ORDER BY ASC/DESC depending on how you want them sorted. Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634541 Share on other sites More sharing options...
jakebur01 Posted September 5, 2008 Author Share Posted September 5, 2008 this what it is like when it is inserted $Month=$_POST["Month"]; $Day=$_POST["Day"]; $Hour=$_POST["Hour"]; $Club=$_POST["Club"]; $Topic=$_POST["Topic"]; $Type=$_POST["Type"]; $Year=$_POST["Year"]; $Starttime = mktime($Hour, 0, 0, $Month, $Day, $Year); Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634695 Share on other sites More sharing options...
Mchl Posted September 5, 2008 Share Posted September 5, 2008 Use CURDATE() and DATE() Mysql Date/Time functions to compare timestamp with current date. Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634701 Share on other sites More sharing options...
jakebur01 Posted September 5, 2008 Author Share Posted September 5, 2008 I am having trouble. $datet=date(); $time=time(); $db = mysql_connect("#", "#", "#"); mysql_select_db("#", $db); $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' AND `Starttime` = '$datet' ORDER BY 'Starttime' desc limit 8", $db); Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634735 Share on other sites More sharing options...
Mchl Posted September 5, 2008 Share Posted September 5, 2008 How about SELECT * FROM life_meeting WHERE TIME(Endtime) > CURTIME() AND DATE(Starttime) = CURDATE() ORDER BY 'Starttime' desc limit 8 Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634743 Share on other sites More sharing options...
jakebur01 Posted September 5, 2008 Author Share Posted September 5, 2008 this one works fine for pulling all of the meetings that have not yet ended $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' ORDER BY MeetingId desc limit 10", $db); but I need to pull only todays meetings and on another page pull only the meetings for the month Starttime is a unix timestamp of the meeting starting time and Endtime is the unix timestamp of the Meeting end time. Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634746 Share on other sites More sharing options...
jakebur01 Posted September 5, 2008 Author Share Posted September 5, 2008 I tried this I still had no action. $datet=date(); $time=time(); $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' AND FROM_UNIXTIME(Starttime) = '$datet' limit 8", $db); Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634780 Share on other sites More sharing options...
jakebur01 Posted September 5, 2008 Author Share Posted September 5, 2008 i tried this if statement and still could not make it happen. $result = mysql_query("SELECT * FROM life_meeting WHERE `Endtime` > '$time' limit 8", $db); while ($myrow = mysql_fetch_array($result)) { $MeetingId = $myrow["MeetingId"]; $Type = $myrow["Type"]; $Username = $myrow["Username"]; $Club = $myrow["Club"]; $Topic = $myrow["Topic"]; $Starttime = $myrow["Starttime"]; $Endtime = $myrow["Endtime"]; $Starttime= date('Y-m-d H:i', $Starttime); $if1=date('Y-m-d', $Starttime); $if2=date('Y-m-d'); if ($if1==$if2) { echo "<small><b>$Starttime</b></small> - $Type<br /><b>$Club</b><br /><a href=\"test7.php?meeting=$MeetingId\"><small>$Topic</small></a><br /><small>$Username</small><br /><br />"; } else { //echo "There are not yet any meetings scheduled for today."; } } Link to comment https://forums.phpfreaks.com/topic/122859-solved-scheduled-events/#findComment-634794 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.