试图在网站上创建中继指示器

I'm having trouble with creating some sort of indicator on a webpage. This should show me if something is turned on or off.

My project concerns on making a "automatic" terrarium controller, with sensors, relays and a raspberry. I'm able to show the sensor readings on a website, updating every minute (using jQuery). At certain times, some relays are activated (which still has to be done, relay arrived today) and I want to see on the site if relay 1 is activated or not and again, updated automatically when this changes. The program to activate some relays is in python, and will also write a txt-file, containing a "0" or a "1" (for "off" and "on").

Then, using for instance a switch (e.g. switch) which should show the state of the relay, according to the txt file. But, I don't seem to get it working. Using PHP If and Else statements, ends up showing both even when using simple images as "indicators" of the relay.

<?php 
    $myfile = fopen("./statusUV.txt", "r") or die("Unable to open file!");
    $status= fread($myfile);        

    if ($status == 1){
           print ('<img src=./images/on.png />');
    }
    else{
           print ('<img src=./images/on.png />');
    }

But, how can different div's been shown, in case of this switch?

Oh, and I have to say, I'm new to PHP, HTML, Python, jQuery etc.

The "button" doesn't have to be clickable, it just have to show the state of the relay (or the output in the file).

If more information is needed, please, let me know! Thanks in advance!

<!DOCTYPE HTML>
<html>
<head>

<title>UV</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <meta name="description" content="" />
  <meta name="keywords" content="" />
  <link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:300,700' rel='stylesheet' type='text/css'>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script src="js/skel.min.js"></script>
  <script src="js/skel-panels.min.js"></script>
  <script src="js/init.js"></script>

  <noscript>
    <link rel="stylesheet" href="css/skel-noscript.css" />
    <link rel="stylesheet" href="css/style.css" />
    <link rel="stylesheet" href="css/style-desktop.css" />
  </noscript>

  <?php 
    $myfile = fopen("./statusUV.txt", "r") or die("Unable to open file!");
    $status= fread($myfile);        
    fclose($myfile);
    switch(intval($status)){
      case 0 : $img = "<img src='./images/off.png' />"; break;
      default : $img = "<img src='./images/on.png' />";break;
    }                           
  ?>    
</head>

<body class="left-sidebar">
  <!-- Wrapper -->
  <div id="wrapper">
    <!-- Header -->
    <div id="header">
      <div class="container">
        <!-- Nav -->
        <nav id="nav">
        <ul>
          <li class="active"><a href="index.html">Data</a></li>
          <li><a href="UVtime.html">UV timer</a></li>
          <li><a href="heattime.html">Heat Timer</a></li>
          <li><a href="ledtime.html">Led Timer</a></li>
          <li><a href="sproeiertime.html">Sproeier Timer</a></li>
          <li><a href="index.html">Apparaten</a></li>
        </ul>
        </nav>
      </div>
    <div id="logo-wrapper">
      <div class="container"> 
        <!-- Logo -->
        <div id="logo">
          <h1><a href="#">Timer</a><span class="tagline"> voor Sproeier</span></h1>
        </div>
      </div>
    </div>
  </div>
  <!-- /Header -->

  <!-- Main -->
  <div id="main-wrapper">
    <div class="divider">&nbsp;</div>
    <div id="main">
      <div class="container">
        <div class="row">
          <div id="sidebar" class="4u"> 
            <?php
              if (isset($img)){
                echo $img;
                echo $status;
            }?>
          </div>                
        </div>
      </div>
    </div>
  </div>
</div>
<div class="divider">&nbsp;</div>

<!-- /Wrapper -->
<div id="copyright">
  <div class="container">
    <p style="font-size:11px">Design: <a href="http://templated.co">TEMPLATED</a> Images: <a href="http://unsplash.com">Unsplash</a> (<a href="http://unsplash.com/cc0">CC0</a>)</p>
  </div>
</div>
</body>
</html>

Assume the var $status = 1 or 0 in the text file. Your code must be like that :

<html>
<head>
<?php
    $myfile = fopen("./statusUV.txt", "r") or die("Unable to open file!");
    $status = fread($myfile);   
    fclose($myfile);    

    switch(intval($status)){
        case 1 : $img = "<img src='./images/on.png' />"; break;
        default : $img = "<img src='./images/off.png' />"; break;
    }

?>
</head>
<body>
<?php 
if (isset($img)){
    echo $img; 
}?>
</body>
</html>

Some PHP-problems has been solved by reseting the server. Apparently that would fix the strange code appearing on the site. Now, after testing various things, it appears that $status remains empty. After trying various techniques, I found that fgets($myfile) would do the trick, instead of the fread($myfile)! Thanks everyone for helping!