Jump to content

Grabbing data from a database at a certain time.


Blake2009

Recommended Posts

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.

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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));

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.