PDA

View Full Version : Help on air script



djaubs89
08-04-2017, 10:39 AM
hello rite no one has helped me out with a script for on air

i know papabear has helped but that script is not working.

were looking for a script that 106themix had on there site when they was running
i know some people use mysql for running there script but i would rather not.

please if anyone can help me with a script like 106themix had that would be "great"

many thanks

GKIye
08-04-2017, 04:04 PM
At this forum of BW You can find the attached script.
It "works", I use it also.
It shows "Artist - Song" at every rotation ... so also if an ID etc is played

Please check the attached zip file
The folder and text file with the code for your website are included

Enjoy !

djaubs89
08-05-2017, 11:57 AM
im looking for an on air script which shows when the djs are on air

but a script what 106themix had

djaubs89
08-05-2017, 12:55 PM
i have this code


<?php //set timezone putenv ('TZ=london/western europe'); mktime(0,0,0,1,1,1970); $day = date("N"); $time = date("Hi"); if ($day == 7) { switch($time) { case ($time >= '0600' && $time <= '0959'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1200'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; default: echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; } } elseif($day == 6) { echo"<img src='images/jukebox.gif' alt='Devil is On-Air Now' class='onair'/>"; } else { switch($time) { case ($time >= '0600' && $time <= '0959'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; case ($time >= '1000' && $time <= '1459'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; case ($time >= '1500' && $time <= '1859'): echo"<img src='images/jukebox.gif' alt='devil' class='onair'/>"; break; case ($time >= '1900' && $time <= '2359'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; case ($time >= '2400' && $time <= '0559'): echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; default: echo"<img src='images/jukebox.gif' alt='devil is On-Air Now' class='onair'/>"; break; } } ?>


but what time zone do i put it in as im in united kingdom

James
08-07-2017, 06:41 AM
Here's a list of supported timezones: http://php.net/manual/en/timezones.php

"Europe/London" is what you are looking to use for the timezone.

James
08-07-2017, 07:07 AM
You could try something like this (whipped this up quickly):



<?php
function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/


// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.php
date_default_timezone_set('America/Los_Angeles');


// Set default text | When a show is not on air, this text will display
$default_on_air = '';


// Shows array, edit this information for each show
$shows = [
[
'show_name' => "Sample Show", // Show name
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 9, // Start Time (24 hour format)
'end_time' => 11 // End Time (24 hour format)
],
[
'show_name' => "The Best Show In The World", // Show name
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 12, // Start Time (24 hour format)
'end_time' => 13 // End Time (24 hour format)
],
[
'show_name' => "Test Show", // Show name
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 14, // Start Time (24 hour format)
'end_time' => 16 // End Time (24 hour format)
]
];


/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////


$now_day = date('l');
$now_time = date('G');


$output = $default_on_air;


for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = $shows[$i]['show_name'];
}
}


return $output;


}
?>


Simply copy and paste this code on your website and then include this code wherever you want the DJ/Show on air to appear:

<?php echo onAirNow(); ?>

Remember to edit the info in the script above the line with your show/dj details, timezone and default text.

Let me know if you have any issues.

djaubs89
08-30-2017, 07:48 PM
so if i want friday saturday and sunday were am i meant to put the images for that

and i don't get this script could you help out please

James
08-30-2017, 09:58 PM
so if i want friday saturday and sunday were am i meant to put the images for that

and i don't get this script could you help out please

You add the shows to the array and change the variables required. For example if you had three shows, two on Friday, one on Saturday and one on Sunday, it would look like this:


<?php function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/

// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.php
date_default_timezone_set('America/Los_Angeles');

// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = ''; // Default text
$default_image_on_air = ''; // Default image

// Shows array, edit this information for each show
$shows = [
[
'show_name' => "Friday Show 1", // Show name
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 9, // Start Time (24 hour format)
'end_time' => 11, // End Time (24 hour format)
'image' => 'http://lorempixel.com/400/200'
],
[
'show_name' => "Friday Show 2", // Show name
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 11, // Start Time (24 hour format)
'end_time' => 14, // End Time (24 hour format)
'image' => 'http://lorempixel.com/400/200'
],
[
'show_name' => "Saturday Show", // Show name
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 15, // Start Time (24 hour format)
'end_time' => 18, // End Time (24 hour format)
'image' => 'http://lorempixel.com/400/200'
],
[
'show_name' => "Sunday Show", // Show name
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 14, // Start Time (24 hour format)
'end_time' => 16 // End Time (24 hour format),
'image' => 'http://lorempixel.com/400/200'
]
];

/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////

$now_day = date('l');
$now_time = date('G');

$output = array($default_on_air, $default_image_on_air);

for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}

return $output;

}
?>

Then when you want to display the show name, simply paste this:


<?php echo onAirNow()[0]; ?>

If you want to display the image, simply paste this:


<?php echo onAirNow()[1]; ?>

------------------------

This code hasn't been tested, so let me know if this doesn't work.

djaubs89
08-31-2017, 09:38 AM
ok so i have this


<?php function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/








// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');








// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = ''; // Default text
$default_image_on_air = ''; // Default image








// Shows array, edit this information for each show
$shows = [
[
'show_name' => "Friday Show ", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20 // End Time (24 hour format),
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
],




[
'show_name' => "Saturday Show", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20 // End Time (24 hour format),
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ],
[
'show_name' => "Sunday Show", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20 // End Time (24 hour format),
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ]
];








/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////








$now_day = date('l');
$now_time = date('G');








$output = array($default_on_air, $default_image_on_air);








for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}








return $output;








}
?>

but were do i put monday tuesday wednesday thursday

djaubs89
08-31-2017, 09:41 AM
1720 ok this script is not working

James
08-31-2017, 11:19 AM
You have put data in a comment rather than the actual script.

Here is the script running perfectly fine:
https://www.tehplayground.com/PLFCyp96cBBFRtBL

I recommend reading a bit more about PHP if you wish to explore scripts like this, otherwise post your show schedule info and I can assist in creating the script. Usually this is a service that I charge for but im happy to guide you on the right track.

I have also wrapped the code in [ CODE ] tags. Please use these so that the code is displayed correctly.

djaubs89
08-31-2017, 12:28 PM
ok mine is working great ;) now how do i change to text colour

James
08-31-2017, 02:05 PM
ok mine is working great ;) now how do i change to text colour

Have a read up on HTML in order to style your text.
https://www.w3schools.com/html/html_styles.asp

djaubs89
08-31-2017, 05:51 PM
i don't see anywere in the script to change the colour of the text though

djaubs89
08-31-2017, 05:57 PM
i want this part of the script $default_on_air = 'No DJ is on air'; // Default text

in red

djaubs89
08-31-2017, 08:57 PM
don't worry i have sorted it, but one small problem. does that script work with the rest of the week?
and will it show my image /images/strawbs.png from 18 to 20 friday saturday and sunday

James
08-31-2017, 09:45 PM
don't worry i have sorted it, but one small problem. does that script work with the rest of the week?
and will it show my image /images/strawbs.png from 18 to 20 friday saturday and sunday

Yes it works with any day as shown in the script comments (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday).
You will have to set up a new array item for each of those days for those time periods.

djaubs89
08-31-2017, 10:16 PM
like this
<?php function onAirNow() { // James' Show On Air Script // http://broadcastingworld.com/
// Set the timezone // See full list of timezones here: http://php.net/manual/en/timezones.europe.php date_default_timezone_set('Europe/London');
// Set default text and default image | When a show is not on air, this text and image will display $default_on_air = 'No DJ is on air'; // Default text $default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image
// Shows array, edit this information for each show $shows = [ [ 'show_name' => "Monday", // 80s 'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 01, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/jukebox.gif' 'show_name' => "Tuesday", // 80s 'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 01, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/jukebox.gif' 'show_name' => "Wednesday", // 80s 'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 01, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/jukebox.gif' 'show_name' => "Thursday", // 80s 'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 01, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/jukebox.gif' 'show_name' => "Friday Show 1", // 80s 'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 18, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ], [ 'show_name' => "Friday Show 2", // 80s 'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 18, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ], [ 'show_name' => "Saturday Show", // 80s 'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 18, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ], [ 'show_name' => "Sunday Show", // 80s 'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday) 'start_time' => 18, // Start Time (24 hour format) 'end_time' => 20, // End Time (24 hour format) 'image' => 'http://urban-radio.co.uk/images/strawbs.jpg' ] ];
///////////////////////////////////////////////////// ////////// DO NOT EDIT BELOW THIS LINE ////////////// /////////////////////////////////////////////////////
$now_day = date('l'); $now_time = date('G');
$output = array($default_on_air, $default_image_on_air);
for($i = 0; $i < count($shows); $i++) { if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) { $output = array($shows[$i]['show_name'], $shows[$i]['image']); } }
return $output;
} ?>DJ Now On Air: <br /><img src="<?php echo onAirNow()[1]; ?>"><br /><h3><?php echo onAirNow()[0]; ?></h3>

James
09-01-2017, 02:31 AM
Could you format it a bit better sorry? Im unable to read the code.

djaubs89
09-01-2017, 10:00 AM
is this ok


<?php function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/


// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');


// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = 'No DJ is on air'; // Default text
$default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image


// Shows array, edit this information for each show
$shows = [
[
'show_name' => "Monday", // 80s
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "Tuesday", // 80s
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "Wednesday", // 80s
'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "Thursday", // 80s
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "Friday Show 1", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "Friday Show 2", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "Saturday Show", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "Sunday Show", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
]
];


/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////


$now_day = date('l');
$now_time = date('G');


$output = array($default_on_air, $default_image_on_air);


for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}


return $output;


}
?>
DJ Now On Air: <br />
<img src="<?php echo onAirNow()[1]; ?>"><br />
<h3><?php echo onAirNow()[0]; ?></h3>

James
09-01-2017, 11:13 AM
Looks good, although Im not sure if you intend to name your shows "Monday", "Tuesday" etc..
You have replaced a comment with "80s".

djaubs89
09-01-2017, 12:14 PM
ok how about now, as i have sorted it out. i can do the rest like add colour etc



<?php function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/


// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');


// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = 'No DJ is on air'; // Default text
$default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image


// Shows array, edit this information for each show
$shows = [
[
'show_name' => "JukeBox", // jukebox
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // jukebox
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // jukebox
'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // JukeBox
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
]
];


/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////


$now_day = date('l');
$now_time = date('G');


$output = array($default_on_air, $default_image_on_air);


for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}


return $output;


}
?>
DJ Now On Air: <br />
<img src="<?php echo onAirNow()[1]; ?>"><br />
<h3><?php echo onAirNow()[0]; ?></h3>

James
09-01-2017, 01:29 PM
Great, working well now?

djaubs89
09-01-2017, 02:10 PM
i will test it on our website and let you know

djaubs89
09-01-2017, 02:35 PM
just gives me this page is not working when i put this script up

<?php function onAirNow() {
// James' Show On Air Script
// http://broadcastingworld.com/


// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');


// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = 'No DJ is on air'; // Default text
$default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image


// Shows array, edit this information for each show
$shows = [
[
'show_name' => "JukeBox", // jukebox
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // jukebox
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // jukebox
'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "JukeBox", // JukeBox
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'

'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
]
];


/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////


$now_day = date('l');
$now_time = date('G');


$output = array($default_on_air, $default_image_on_air);


for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}


return $output;


}
?>
DJ Now On Air: <br />
<img src="<?php echo onAirNow()[1]; ?>"><br />
<h3><?php echo onAirNow()[0]; ?></h3>

you try http://urban-radio.co.uk/test.php

James
09-01-2017, 02:45 PM
You are missing brackets in between the shows in the array. Its not valid PHP.
Please wrap your code in CODE tags for ease of readability and unicode support.

This should work (Playground: https://www.tehplayground.com/r15xCfmk1wcOzRuF):

<?php function onAirNow() {// James' Show On Air Script
// http://broadcastingworld.com/




// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');




// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = 'No DJ is on air'; // Default text
$default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image




// Shows array, edit this information for each show
$shows = [
[
'show_name' => "JukeBox", // jukebox
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // jukebox
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // jukebox
'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // JukeBox
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
]
];




/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////




$now_day = date('l');
$now_time = date('G');




$output = array($default_on_air, $default_image_on_air);




for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}




return $output;




}
?>
DJ Now On Air: <br />
<img src="<?php echo onAirNow()[1]; ?>"><br />
<h3><?php echo onAirNow()[0]; ?></h3>

djaubs89
09-01-2017, 03:00 PM
yep now its working :) i have also added colour to the text as well :) thank you very much

djaubs89
09-01-2017, 03:17 PM
thing is now when the dj is on the air will it automatically change the image instead of having to refresh the page?

djaubs89
09-01-2017, 06:26 PM
1721 the image has not changed, whats going on what am i doing wrong?

djaubs89
09-01-2017, 09:27 PM
anyone here to help?

James
09-02-2017, 01:00 AM
PHP is static, you would have to use a JS framework to pull that info in automatically without refreshing the page.

Either using AJAX or .load():
http://api.jquery.com/load/

djaubs89
09-02-2017, 10:31 AM
ok wich code on that page am i using?

James
09-02-2017, 10:39 AM
This will take some extra time for me to explain a whole new coding language to you sorry. You will have to read the page yourself and learn it, otherwise I can charge for my services.

Let me know if you have any issues.

djaubs89
09-02-2017, 10:46 AM
so your saying that php code wont work when a dj is on air? im due on air tonite at 18:00 so it wont show my image

James
09-02-2017, 12:18 PM
PHP is a server side language that will execute the script to fetch the DJ on air. The script will only load the DJ on air upon page load. As in, if you load the page at 17:59, and the click goes to 18:00, the DJ on air will not update.

You asked for a solution to have your website automatically refresh the DJ on air so you wouldnt have to refresh the page when the click ticks over. For this, you need a front-end language such as Javascript/JQuery to tell it to fetch the current dj on air every 30 seconds (or thereby).

The script you have now works fine, it will display the DJ on air when a user visits your website. But if you want it to automatically update the DJ on air without the page refreshing, you will need to use JQuery to make that happen.

djaubs89
09-02-2017, 12:20 PM
oh ok so i won't be able to see the change in the script then?

as i have friday saturday and sunday set for start time: 18:00 End Time: 20:00

djaubs89
09-02-2017, 12:26 PM
1722ok so i have this, were would i put it

James
09-02-2017, 12:27 PM
What do you mean? Of course you will see the changes.

djaubs89
09-02-2017, 12:28 PM
1723i have this were would i put the code. it says put meta tag in the head but wich head

James
09-02-2017, 12:34 PM
Between the

<head></head>
tags.

djaubs89
09-02-2017, 12:37 PM
so it would go <head>meta</head>

James
09-02-2017, 12:38 PM
https://www.w3schools.com/tags/tag_head.asp
Google is your friend

djaubs89
09-02-2017, 12:47 PM
ok think i have it

<!DOCTYPE html>
<html>
<meta http-equiv="refresh" content="30"/>
<head>


</head>


<body>
<div align=right><!DOCTYPE html>
<html>
<body>


<p><font color="red"><?php function onAirNow() {// James' Show On Air Script
// http://broadcastingworld.com/








// Set the timezone
// See full list of timezones here: http://php.net/manual/en/timezones.europe.php
date_default_timezone_set('Europe/London');








// Set default text and default image | When a show is not on air, this text and image will display
$default_on_air = '<p><font color="red">No DJ is on air'; // Default text
$default_image_on_air = 'http://urban-radio.co.uk/images/jukebox.gif'; // Default image








// Shows array, edit this information for each show
$shows = [
[
'show_name' => "JukeBox", // jukebox
'day' => "Monday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // jukebox
'day' => "Tuesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // jukebox
'day' => "Wednesday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[
'show_name' => "JukeBox", // JukeBox
'day' => "Thursday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 01, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/jukebox.gif'
],
[


],
[
'show_name' => "80's Request", // 80s
'day' => "Friday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Saturday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
],
[
'show_name' => "80's Request", // 80s
'day' => "Sunday", // Day (Monday/Tuesday/Wednesday/Thursday/Friday/Saturday/Sunday)
'start_time' => 18, // Start Time (24 hour format)
'end_time' => 20, // End Time (24 hour format)
'image' => 'http://urban-radio.co.uk/images/strawbs.jpg'
]
];








/////////////////////////////////////////////////////
////////// DO NOT EDIT BELOW THIS LINE //////////////
/////////////////////////////////////////////////////








$now_day = date('l');
$now_time = date('G');








$output = array($default_on_air, $default_image_on_air);








for($i = 0; $i < count($shows); $i++) {
if($shows[$i]['day'] == $now_day && $shows[$i]['start_time'] >= $now_time && $shows[$i]['end_time'] < $now_time) {
$output = array($shows[$i]['show_name'], $shows[$i]['image']);
}
}








return $output;








}
?>
DJ Now On Air: <br />
<img src="<?php echo onAirNow()[1]; ?>"><br />
<h3><?php echo onAirNow()[0]; ?></h3></font></p>
</body>


</html>

djaubs89
09-02-2017, 05:07 PM
i dont get it i have put 18 for start time and 20 for end time its not working

ultra89
06-13-2018, 03:13 PM
rite one last question, how would that code show when my dj's are online as well

RDJUser
06-13-2018, 03:31 PM
You've asked this question many many times and IF the answers haven't sunk in by now then that's NOT our fault....

I'm imagining a lot of people around here are getting just a tad bored with your pathetic repetitive questions...

I'm going to suggest to James that he locks this thread

GKIye
06-13-2018, 06:58 PM
This topic is started at April 8, 2017


James, the founder of BW has provided several scripts, links and details about several scripts
He even provided a script to show "the online dj"
James is a "tech guy" ... when he writes a script, it gonna show everyone the right content.

rite one last question, how would that code show when my dj's are online as well
I beg You and fellow (new) members to "read" what is written, to test Yourself scripts, to discover the download area of your stream provider ... and "to learn" how things are working.


We as alltime members, since 2008 / 2009, to BW have learned through the years with ups and downs how scripts are acting, are working, where they can be found, how to adjust them etc ...
Most of Us are selfmade people since decades (I am into broadcasting since 1978, so been there - done that).
Before these kind of forums about broadcasting were online We had to "find" at any place possible "some info" to what We were searching for.

So please, understand Our point of view as pro and former pro broadcasters, including every hobby broadcaster that "searching & learning" isn't a shame.
However please do not ask at all time the same or similar questions.
Use the "search" tool at this website !!
Since BW is founded in 2008, and in earlier days at other forums, We have seen these kind of questions very very very often.

If some members do not want, or are not able to read the answers, I suggest that kind of people to stop with their broadcasting "dream".

Last but not least ...
At this link You can find the "online dj" script provided by James ... Please read it, learn it & use it !
https://www.tehplayground.com/PLFCyp96cBBFRtBL

Hereby this thread is closed