Blake2009 Posted December 10, 2009 Share Posted December 10, 2009 Hello, I don't know if this is possible and I am a noob with PHP just learning. I am building a internet radio station and I can store all my schedules of DJ's/Shows etc.. and I can get it to grab it. I was wondering if you could grab data from a database at a certain time or if theres some other way around this. Basicially I want it to show "Up Next: 11pm - Show Name" like at http://www.offthechartradio.co.uk/ (top right cornor) How would I go about doing that?. Regards, Blake. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/ Share on other sites More sharing options...
Tonic-_- Posted December 10, 2009 Share Posted December 10, 2009 If your web host uses cPanel I advise to lookup "how to setup conjobs using cpanel" or something similar. Cronjobs are really your best bet to get this. Cronjobs aren't hard either but it will fit what you want to do. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975109 Share on other sites More sharing options...
Blake2009 Posted December 10, 2009 Author Share Posted December 10, 2009 Alright thanks for the info, I didn't even think of setting up a cron job in my cPanel. I will have a look around and see what I can find, I will let you know of anything I find, if not then I will re-ask here in this topic. Regards, Blake. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975112 Share on other sites More sharing options...
Blake2009 Posted December 10, 2009 Author Share Posted December 10, 2009 Hey, sorry for the double post. I have no idea on what to search. Any ideas from anyone?. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975116 Share on other sites More sharing options...
Tonic-_- Posted December 10, 2009 Share Posted December 10, 2009 Try this. http://www.trap17.com/index.php/cron-jobs-cron-jobs-cpanel_t6321.html Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975117 Share on other sites More sharing options...
Blake2009 Posted December 11, 2009 Author Share Posted December 11, 2009 Cheers for that, had a read through it. My problem is, how? Lol. I am a complete noob and im sorry for this but we all have to start somewhere. Here is my MONDAY table: Day TIME SHOW DJ Monday 00:00am Early mornings Auto DJ 06:00am Wake up with us! Auto DJ 12:00pm Lunch Talk Blake Reynolds 13:00pm Non-Stop Auto DJ 14:00pm Top Hits Blake Reynolds 15:00pm Rock Hour Sam Arrowsmith 18:00pm News & Weather Blake Reynolds 19:00pm Cranked Aaron Cola 21:00pm The Biggest Hits Sebastien Vermeire 22:00pm Counter Strike Hour Sebastien Vermeire 23:00pm Last Orders Blake Reynolds So say like it is 18:00PM playing News & Weather, I want it to say under it "Up Next at 19:00PM - Cranked". I have no idea on how to do this, even with a cron job and I read through that post a few times that Tonic gave me. Im confused, would someone be prepared to go into a little detal for me, please. Regards, Blake. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975131 Share on other sites More sharing options...
Blake2009 Posted December 11, 2009 Author Share Posted December 11, 2009 Sorry for the bump but I really need help on this soon as my launch in on Saturday. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975174 Share on other sites More sharing options...
Blake2009 Posted December 11, 2009 Author Share Posted December 11, 2009 Anybody got the sligtest idea?. (Yet again, sorry for the bump). Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975374 Share on other sites More sharing options...
SamW Posted December 11, 2009 Share Posted December 11, 2009 Eh; you could do a whole lot of if, elseif's... (You will have to make this yourself; however...) if time=<18:59 { echo "Up next - News & Weather" } Obviously that's not usable; but you get the idea. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975377 Share on other sites More sharing options...
Blake2009 Posted December 12, 2009 Author Share Posted December 12, 2009 I don't really want to use a lot of "else if"'s, mainly because of the size the script will be AND not to mention calling the time function in. I am still looking for idea's on how to do this, if anyway wishes to help Regards, Blake. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975765 Share on other sites More sharing options...
cags Posted December 12, 2009 Share Posted December 12, 2009 None of the advice given so far fits in with my understanding of the problem. It would appear that you wish to basically display on the site which program is next up. Provided you stored the time in the database using a valid TIME/DATE format (which you should) it's just a simple query that you require. SELECT show WHERE time > NOW() ORDER BY time ASC LIMIT 1 Providing more details on the database table structure would help us provide more exact information. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975927 Share on other sites More sharing options...
ignace Posted December 12, 2009 Share Posted December 12, 2009 @Tonic: Like cags said "None of the advice given so far fits in with my understanding of the problem. " I don't understand why you even would point the OP in the direction of CRON?? @cags: You mean: SELECT * FROM show WHERE time > NOW() ORDER BY time ASC LIMIT 1 CREATE TABLE playday ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id)); CREATE TABLE playhour ( id tinyint NOT NULL auto_increment, start time, PRIMARY KEY (id)); CREATE TABLE playlist ( playday_id tinyint NOT NULL, playhour_id tinyint NOT NULL, show_id tinyint NOT NULL, dj_id tinyint NOT NULL, PRIMARY KEY (playday_id, playhour_id, show_id, dj_id)); CREATE TABLE show ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id)); CREATE TABLE dj ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id)); Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975941 Share on other sites More sharing options...
cags Posted December 12, 2009 Share Posted December 12, 2009 @cags: You mean: SELECT * FROM show WHERE time > NOW() ORDER BY time ASC LIMIT 1 That is indeed what I meant, damn my fingers, just for once I wish they'd write what my brain told them to. Their normal trick is to random add or omit 'ly' to/from the end of words. I can see why people assumed cRON, I'll be honest when I read the thread title I thought it was going to be a thread where cRON would be the solution, but once you read the description it really doesn't make much sense. Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975948 Share on other sites More sharing options...
ignace Posted December 12, 2009 Share Posted December 12, 2009 That is indeed what I meant, damn my fingers, just for once I wish they'd write what my brain told them to. Hehe yeah those damn body parts don't they know they should obey the almighty brain? Quote Link to comment https://forums.phpfreaks.com/topic/184707-grabbing-data-from-a-database-at-a-certain-time/#findComment-975971 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.