Click to See Complete Forum and Search --> : Easy question...I think ?


Mr Slabi
10-20-2003, 08:17 PM
I have a bit of php script that fetches info about who is online and what is playing at the moment (radio page).

I am wondering if there is a way I can create a page (password protected of course) with multiple DJ titles, once the active dj selects his name from that page, the php script will fetch that info automatically.

#Defaults, Being Online Changes These
$text = "off";
$dj = "Dj Rave";
$cursong = "Offline";
if ($lowonair) {
$text = "on";
$cursong = $losong;
}

I would like the $dj = "dj Rave"; to be the item that gets fetched from the new html page.

Anyone have any ideas....thanks for any help.

Jona
10-20-2003, 09:37 PM
Are you reading from a database or a text file? You should be able to select the value from the database or parse the text file for the information and set it to a variable pretty easily. I may have misunderstood your question... Perhaps you should use a querystring and use the $_GET autoglobal variables to select the value you want, and send that from page to page...

[J]ona

Mr Slabi
10-20-2003, 10:00 PM
It would be html based I suppose. I was wondering If there was a way to have a form (seems easiest) to create a file. Then just have that "$dj" tag pull up the last line on the file the form created.

Does that help any? I really do suck with php and the code I am using now is a standard for shoutcasting. I am trying to see if this could be a workaround to manually changing the value every time a new user starts dj'ing?

It would seem I am a bit of a moron...Lemmie give a link to the page so you can get an idea of what I mean.

KRavRadio.com (http://www.kravradio.com)

lemmie show you the whole bit, maybe it will help?

<?php
$bitrate = "";
include ("config.php");
include ("scastxml.php");
if($success!=2 && $bitrate){
$lowonair = true;
$locount = $currentlisteners;
$lomax = $maxlisteners;
$losong = $song[0];
$lobitrate = $bitrate;
}
else {
$lowonair = false;
}

#Defaults, Being Online Changes These
$text = "off";
$dj = "Dj Rave";
$cursong = "Offline";
if ($lowonair) {
$text = "on";
$cursong = $losong;
}
else {
$locount = "Off";
$lomax = "line";
}

print "<img src=../pics/radio/vumeter" . $text . ".gif border=0 align=left>";
print "<img src=../pics/radio/" . $text . "air.gif border=0 align=left>";
print "<img src=../pics/radio/vumeter" . $text . ".gif border=0 align=right>";
print "<font face=verdana size=1 color=#c0c0c0><div align=left><br><br><br>";
print "Current Listeners-" . $locount . "/" . $lomax . "<br>";
print "Current DJ - " . $dj . "<br>";
print "Current Song - " . $cursong . "<br>";
?>

Does that help any.....Thanks for your time :)

Jona
10-20-2003, 10:15 PM
Is the user submitting a form every time he changes the song/station he is listening to, or are you doing all of this processing via links? If by form, you can overwrite the same file over and over again (named differently depending on which user is logged in, so you'll have a new file for each user), or a better way would be to set a new column in your database and select its value depending on which user is logged in. (So, SELECT `name_of_new_column` FROM `name_of_users_table` WHERE `username` = $loggedin_username would be the pseudo-code in MySQL, if that is the database you are running on.)

[J]ona

Mr Slabi
10-20-2003, 10:30 PM
The dj title only changes about 3 times a day...So I was thinking...Would a pre-selected set of links that I set up be better suited to make it easy on me.

It would be like this...The new dj takes over the stream, then goes to pre-selected page and clicks on his link to change the displayed dj name.

I'm sorry if I sound like a newb to this, Ummm...But I kinda am :)

Thanks for your time.

Jona
10-20-2003, 10:35 PM
You could do that...

HTML link:

<a href="your_php_file.php?dj=whatever_the_dj_is">DJ</a>


PHP code:

if(isset($_GET["dj"]))
{
$dj = $_GET["dj"];
} else {
$dj = "whatever it should equal if it isn't set";
}


[J]ona

fyrestrtr
10-23-2003, 02:55 AM
Another way of writing Jona's code :



$dj = (isset($_GET['dj']) ? $_GET['dj'] : "No DJ Selected";