CraftifiedLIVE Posted February 3, 2012 Share Posted February 3, 2012 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; ?> Quote Link to comment https://forums.phpfreaks.com/topic/256336-changing-image/ Share on other sites More sharing options...
waynew Posted February 3, 2012 Share Posted February 3, 2012 What do you mean by change an image? Could you elaborate on that a bit more? Quote Link to comment https://forums.phpfreaks.com/topic/256336-changing-image/#findComment-1314119 Share on other sites More sharing options...
CraftifiedLIVE Posted February 3, 2012 Author Share Posted February 3, 2012 Ahh sure, what I mean is when Streamstatus = online I want offline.png to be changed to online.png and vice versa if you get what I mean Quote Link to comment https://forums.phpfreaks.com/topic/256336-changing-image/#findComment-1314133 Share on other sites More sharing options...
Andy-H Posted February 4, 2012 Share Posted February 4, 2012 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 .'" >'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/256336-changing-image/#findComment-1314288 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.