I have two columns in my MySql database
activeAt(timestamp)
activeAtTime(time)
I want to fetch data that are less than activeAtTime(timestamp) and activeAt(time)
The problem I'm facing in my code is
if activeAt is 25th may & activeAtTime is 5pm of an particular post
and If the fetch the data with below code at 26th may 2pm it is not getting listed, but if i fetch at 26th may 5:30 pm the post is getting listed
(i used medoo, but you can suggest any query)
"activeAt[<=]" => date("Y-m-d"),
"activeAtTime[<=]" => date("H:i")
eg a post with activeAt and activeAtTime
If i make a fetch request at 25th may, 8 am this post is not getting listed
I'm trying to make a blogs that posts based on scheduled time and date
i tried bootstrap datetime picker but it didn't work
Is there any way i can combine activeAt and ActiveATtime
So that the above logic works
What will be the most efficient way to do it?.
Related
I am using an HikVision Dual Lens People Counting Camera that tracks the amount of people that enter/exit a location by the hour. The data that is exported from the camera is automatically put into an excel file with the format being as follows:
Time Entered
People Entered
00:00:00.000
43
01:00:00.000
87
02:00:00.000
62
The file is then uploaded to my website and put into the database under the same format. However, it isn't good enough since I want to be able to query the data based on a specific day, for example how many people entered on every Monday, how many people entered from 2/10/2022 to 2/19/2022, etc. I have been trying to figure out a way for my table to have the date ALONG with the breakdown by hour, so for example:
2022-02-19 00:00:00
2022-02-19 01:00:00
2022-02-19 02:00:00
2022-02-19 03:00:00
My issue is, the software for the camera builds the excel sheet and conforms to the table above, and has no spot to include the date. I was wondering how I could get the date and the hourly breakdown of people entered all into one database so that I can query anything I need.
Sorry if this is a little incomprehensible, it's hard explaining my exact issue. I can provide updates if need be! Thank you so much for any and all help!!
If you cannot act on the system that generates the records in your database, a good option could be to add a date field to your table in order to get the day when the records were inserted.
ALTER TABLE mytable
ADD day DATETIME NOT NULL DEFAULT NOW();
I'm making a web app in PHP that calculates vacations and some are fixed, say for example, Christmas, so instead of adding dates like
2015-12-25
2016-12-25
2017-12-25
2018-12-25
Is there any way to add something like
*-12-25
That accounts for every 25th of December of ALL the years? I know PHP has this but since I'm getting the dates from a Vacation Dates table that is populated by the admin I can't figure out how to do this in PHP, else I'll have to default to add 10 years to each entered date
I have search over php mysql recurring events but didnt find anything exactly like i want.
I want to develop event sheduler in php mysql in which user add reccuring events based on daily,weekly,montly,yearly patterns using html form which is stored in mysql using php.
Like for example
user will enter start date,end date, what time event will happen(like 4:30pm) and duration of the event(like 2 hrs so it will make 430pm to 630pm event) with repeating patterns.For example event will repeat after 3 days , on monday and wednesday every week or after every two weeks, every 10th day of month or every 10th day after two months, on specific date every year or without any repeating patterns just add event for any specific date .
This information will be taken from user using html form and will be stored in mysql database and than it needs to display user upcoming events(e.g consider today is 13th july 2013 if recurring event is sheduled for 15th july 2013 it will consider as upcoming events) or events in the past(e.g consider today is 13th july 2013 if event is sheduled for 10th july 2013 it will be consider as past event) using php in two different ways using html table and arshaw full calendar.
I need help how i store event information in mysql database and than pull it using php and display upcoming or past events in html table and also be to integrate it arshaw full calendar.
This sort of stuff is already working in musicteacherhelper.com which also used php and mysql for implementing so i need to know is there any open source code available to implement this functionality.
Any help in this regard will be highly appreciated.
Thanks
Talha
use industry standard RRULE to store the informaton and some metadata of event in some mysql table for search purpose (example : date range)
http://www.kanzaki.com/docs/ical/rrule.html
demo : http://jkbr.github.io/rrule/
there are js and php libraries available for the same.
In teaching myself php and mySQL a year or two ago, I created a movie database for the theater I work at, to help automate the more mundane web updates that need to be done weekly. So far this only pertains to film information (title, ratings, synopsis, start date) - but does not include showtimes, but lately I've thought it might be fun to see if it's possible to build on this aspect of the site.
My initial idea was to build a table that displayed showtimes via date groups (ie 5/15 - 5/20), but it was suggested that submitting times for individual days would probably be more useful from a user perspective (ie the showtimes for 5/15 are...), especially since there are occasionally changes and cancellations throughout the week due to special events.
Problem I'm having even starting this - is how to submit more than one date at once. Would it be possible, in the form, to have a 'start date' and 'end date' and have the single form submit all the times input on those two dates and all the dates inbetween?
From a back-end perspective submitting the same 4 or 5 showtimes every day, 7 days a week for 10 to 14 films a week is more work for US than just putting the times in manually in dreamweaver - so I'm just trying to figure out how to make the process easier for us behind the scenes. If we could batch insert a set of showtimes, then we could go back through and edit the individual days that have special/cancelled times (which would probably mean building in a 'draft, live, hidden' system - but I've got at least a basic knowledge of how to go about that.
I've got a very basic table set up for showtimes with (user end example of what I'm aiming for here):
MOVIE_ID (links with the movie info database to pull in film info - title, runtime, etc)
sched_date (uses datetime to set a specific showtime on a specific date)
I guess I might have to abandon using datetime if there's any way to do this?
Any help would be hot! Much thanks!
You can have 2 date fields with names from_date and end_date in your PHP form. In your PHP form submit code you then need to use the DateTime class and start from from_date and use the DateTime::add method to loop till end_date is reached. Please note you need to first convert the 2 dates i.e. from_date and end_date to datetime using either new DateTime('YYYY-MM-DD') or using DateTime::createFromFormat.
In the loop simply send insert commands to MySQL to insert the rows to your DB.
I have a MySQL table titled 'my_cal' with a column titled 'start_time' for particular events in the calendar.
The way items are added to the database, there are no overlapping events.
There also may not be an event for a particular day/time either, in this case we leave it blank or put a blank value.
My problem lies in the fact that running 00:01AM to 23:59PM for each day sequentially would be easy, but I want to get the data as:
Mon 00:00, Tues 00:00, Wed 00:00, etc, etc
Mon 01:00, Tues 01:00, Wed 01:00, etc, etc
Mon 02:00, Tues 02:00, Wed 02:00, etc, etc
This is to build a table with 25 Rows (24 hours of the day + 1 for title), and 8 columns (7 days of the week + 1 hourly title)
Here is an example of how the calendar should look as far as HTML Table structure goes:
http://www.wmnf.org/programs/grid
I have made an attempt at getting this to work,
Running through the MySQL results, and saving them as
$data[$hour_of_the_day][$day_of_the_week]
I would then have recursive while() loops for each hour, and then each day,
$hour=0;
while($hour > 24)
{
$day=0;
while($day > 8)
{
if(isset($data[$hour][$day]))
{ echo "event"; }
$day++;
}
hour++;
}
I believe this may get me by, but it does not seem very elegant.
I also wanted the time the calendar started to be 6:00AM, and not 12:00AM.
I wanted the first day listed to be today - 3 (to center the calendar on today)
I.e:
$calendar_begin_day = date("j", mktime()) - 3;
I am looking for any way to make this easier, as I want it to run as efficient as possible due to large hit count.
Thanks
When you retrieve your results, I think you can use the ORDER BY clause and date functions on your to order them by hour and then by day and not the other way round. This way you can iterate on results and avoid storing your data in a php array.