Jump to content

Changing image


CraftifiedLIVE

Recommended Posts

Any chance you could help me out with some probably simple code ? I need to change an image when the script change state. So instead of $Streamstatus "off"or "on" I would like to change an image. Cheers :)

 

<?php 
    $request =  'http://api.own3d.tv/liveCheck.php?live_id=';
    $arg = 'Zerkilive';
    $session = curl_init($request.$arg);

    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($session);
    curl_close($session);

    if (preg_match("/true/",$response, $result)) {
       $streamStatus="on";
   $color="green";
    } else {
       $streamStatus="off";
       $color="red";
   }
   
    echo $streamStatus;

?>

Link to comment
https://forums.phpfreaks.com/topic/256336-changing-image/
Share on other sites

Any chance you could help me out with some probably simple code ? I need to change an image when the script change state. So instead of $Streamstatus "off"or "on" I would like to change an image. Cheers :)

 

<?php 
    $request =  'http://api.own3d.tv/liveCheck.php?live_id=';
    $arg = 'Zerkilive';
    $session = curl_init($request.$arg);

    curl_setopt($session, CURLOPT_HEADER, false);
    curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
    $response = curl_exec($session);
    curl_close($session);

    if (preg_match("/true/",$response, $result)) {
       $streamStatus="on";
       $image = 'http://www.csar.cfs.ac.uk/csar/images/up.gif';
      $color="green";
    } else {
       $streamStatus="off";
       $image = 'http://www.csar.cfs.ac.uk/csar/images/down.gif';
       $color="red";
   }
   
    echo '<img src="'. $image .'" >';

?>

Link to comment
https://forums.phpfreaks.com/topic/256336-changing-image/#findComment-1314288
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.