0

Hey Guys,

Struggling a bit here trying to get my head around something. I'm not a PHP expert, but I feel I've come a long way in the 6 months or so I've been learning it.

Anyway, I thought I would pluck up the courage to build my own custom CMS system, it's going pretty well at the moment, have the major basics covered and are working nice and smoothly, however, I'm having a little bit of trouble with something.

I want to be able to run a MySQL Query using PHP every time that specific page is loaded. Th query I want to run is I want PHP to search the Database for records that have been added in the last 30 minutes... and display certain tables that match that criteria.

Could anyone help me out with this at all? The table type that contains the date and time is "Datetime" (not timestamp) ... I know how to do a basic MySQL query, but seen as the time changes the query would need to change, so I'm slightly confused at how to do this at this point.

All help would be greatly appreciated!

Edited by brown23: n/a

3
Contributors
2
Replies
4
Views
6 Years
Discussion Span
Last Post by lordspace
0

Maybe I didn’t understood your question but if I did lets say that we have a table that has ID (int 10) , TITLE (varchar 255) and TIME_STAMP(int 10) … evert time we use insert or update we just turn TIME_STAMP in date(“U”) … so it easy to find what is there new … in the WHERE clause we just take date(“U”) - (date(“U”)*60*30) for a half hour. Of course there are several other ways but I am pointing the most easy one without any other knowledge of MySql functions and sets.

0

You need something like this.

SELECT * FROM my_table WHERE activity_date BETWEEN DATE_SUB(NOW(), INTERVAL 30 MINUTE) AND NOW()
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.