How would I go about doing this function?

Discussion in 'HTML & Website Design' started by allthegoodnamesweretaken, Feb 15, 2011.

  1. #1
    Hi. I have a problem, and would be most grateful for any help given :) My site URL is http://bit.ly/einIPE (please refrain from posting the true URL due to indexing purposes). Read below for the details.

    The site embeds a video which is located in within the DIV ID "stream". The code looks like this:
    <?php include("streams/hqstream.txt"); ?>
    PHP:
    As you can see there are two buttons near the top - "High Quality" and "Low Quality". What I want to achieve is that when "High Quality" is clicked, the code includes the "hqstream.txt" file; but if the "Low Quality" button is clicked the code should change and then include the "lqstream.txt" file.

    Does that make sense? How would I go about achieving this? I'm aware that it may not work using the php include, and I may have to use an iFrame instead.

    Thanks for any help in advanced.

    PS. I didn't post this in the PHP forum as the solution will probably involve a mix of HTML/PHP/JAVASCRIPT etc and isn't a PHP specific question.
    John.
     
  2. Mike224

    Mike224 Well-Known Member

    Messages:
    80
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    100
    #2
    Why dont you include a php file (say mystream.php)

    and within mystream.php create a method getStream($quality), from your main php file call this method: $myString = getStream($selectedQuality){}

    Within mystream.php:
    This is demi-code (untested), but you can get the idea
    I dont know whats in the txt file, but file_get_contents will return a string, if you want an array use file() ...etc
     
    Last edited: Feb 15, 2011
    Mike224, Feb 15, 2011 IP
  3. allthegoodnamesweretaken

    allthegoodnamesweretaken Peon

    Messages:
    374
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thats a bloody great idea Mike, I thought about that but didn't quite have the expertise.

    Okay, now I'm including "mystream.php" with the code you provided me, how do I set it so that the buttons control the selection?

    Thanks so far! :)

    PS. The text files just contain the video embed codes.