Question:

How can I make a script that can choose what part of a PHP file to show on a website?

by  |  earlier

0 LIKES UnLike

Ok, this is sort of hard to explain. I'm working in a radio statues script right now and we are setting up a mode called, Idle mode. Idle mode will be enabled when no one is DJing on the website. Does anyone know a script that enables someone to select what part of the file to choose in a PHP File?

For example, a DJ in the DJ Control Panel can select an option that says 'Enable Idle Mode' and then in the Radio Statues it goes automatically from the radio stats (Song, DJ, Bitrates) to a message saying 'The radio is currently on Idle Mode'.

I've bee going crazy trying to figure out how to do this, if anyone can help me it would be great!

 Tags:

   Report

3 ANSWERS


  1. The way I would do this is simple.

    Create MySQL database. Have a table fo rwhatever, and in that table, have a value called "mode" ( just as an example ), then for the value of "mode" have it change.

    Like if the user clicks a button to set it idle, send this to mysql database:

    UPDATE (Table name) SET mode = 'idle'

    and if then a DJ comes along, and clicks "Not idle" button...(lol), you could use:

    UPDATE (Table name) SET mode = 'active'

    Then just have a little script that reads this value, and if its idle display this, and if not, display that. ( Simple if statement would do just fine. )


  2. Sounds like you just want an input type of "radio".

    http://www.echoecho.com/htmlforms10.htm

  3. You are looking to execute one part of the script if a variable is set and another if it is not.  Please correct me if I misunderstood your question.

    The problem revolves around the fact that php scripts are stateless, ie, they don't remember their settings from one load to the next.  So as a result, you should write the 'idle mode' variable value to a file and/or to a database entry that the user script checks each time it loads.

    To write/read from a file : http://www.php.net/fopen

    use the different options to write the variable from the DJ control panel and to read it back for the users.

    Alternatively, if you are using the databases, you can added a field somewhere that hold true or false for when the station is idle or not.

Question Stats

Latest activity: earlier.
This question has 3 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.