kamal213 Posted January 10, 2012 Share Posted January 10, 2012 Hi guys I have a script which displays the events on my calender throught the help of this code. In summary I basically was wondering how I could modify this code to display for events with a start and finish date: IF(isset($events[$i])){ echo "<div align=\"left\"><span class=\"eventinbox\">\n"; while (list($key, $value) = each ($events[$i])) { echo " <a href=\"javascript:MM_openBrWindow('event.php?id=$value','','width=500,height=200');\">" . $event_info[$value]['1'] . " " . $event_info[$value]['0'] . "</a>\n<br>\n"; } echo "</span></div>\n"; } That above is the display the events on the calender and here is the select query: $sql = mysql_query("SELECT * FROM the_event WHERE event_month='$month' AND event_year='$year' ORDER BY event_time"); while($info = mysql_fetch_array($sql)){ //planning to treat this as the event start date$day = $info['event_day']; //I just added this column which would be the event end date$day2 = $info['event_day2']; $event_id = $info['events_id']; $events[$day][] = $info['events_id']; $event_info[$event_id]['0'] = substr($info['event_title'], 0, ;; $event_info[$event_id]['1'] = $info['event_time']; } Please let me know if you need more info Thanks Quote Link to comment https://forums.phpfreaks.com/topic/254724-two-date-event-code-help/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 10, 2012 Share Posted January 10, 2012 See the logic in this post - http://www.phpfreaks.com/forums/index.php?topic=351087.msg1658041#msg1658041 Quote Link to comment https://forums.phpfreaks.com/topic/254724-two-date-event-code-help/#findComment-1306123 Share on other sites More sharing options...
kamal213 Posted January 10, 2012 Author Share Posted January 10, 2012 Thanks for your reply! From your reply on dmhall0's post its seems you would have to put the events in an array in didnt really understand the sql query i.e. $query = "SELECT * FROM health WHERE '$year-$month' BETWEEN EXTRACT(YEAR_MONTH FROM event_start) AND EXTRACT(YEAR_MONTH FROM event_end) ORDER BY id"; . Could you give an example of how it would apply to me (Apologies for being a pain I am still learning php - this project is very difficult) Quote Link to comment https://forums.phpfreaks.com/topic/254724-two-date-event-code-help/#findComment-1306138 Share on other sites More sharing options...
kamal213 Posted January 10, 2012 Author Share Posted January 10, 2012 thinking about giving up been battling this since last week...need help despirately Quote Link to comment https://forums.phpfreaks.com/topic/254724-two-date-event-code-help/#findComment-1306154 Share on other sites More sharing options...
PFMaBiSmAd Posted January 11, 2012 Share Posted January 11, 2012 What exactly about that query do you need help understanding? Even if you can not write a query, you should be able to read it and get the gist of what it is doing, possibly after you research what the mysql EXTRACT() function does or what the BETWEEN comparison does. Quote Link to comment https://forums.phpfreaks.com/topic/254724-two-date-event-code-help/#findComment-1306456 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.