Back to Thermistor and Solar Cell by John Schimmel

<?php

include "dbconnect.php";

//if someone requests // log.php?flip=1 then show the data flipped by the dateTime field if ($_GET['flip'] == "1") {

    $results = mysql_query("SELECT * FROM sensors ORDER BY dateTime desc");

} else {

    //query the database
    $results = mysql_query("SELECT * FROM sensors");

} ?>

<html>

<head> <style type="text/css">

a {

    text-decoration:none;

} a.info{

    position:relative; /*this is the key*/
    z-index:24;
    text-decoration:none}

a.info:hover{z-index:25; background-color:#f00} a.info span{display: none}

a.info:hover span { font-size:17px;

    display:block;
    position:absolute;
    top:2em; left:2em; width:15em;
    border:2px solid #000;
    background-color:#FFF;// color:#000;
    text-align: center;

}

li {

    list-style-type:none;

z-index:3; font-size:20%; }

li.thermistor a.info{

    color:blue;

}

li.solar a.info{

    color:red;

}

li.thermistor a.info:hover {

    font-weight:bold;

} li.solar a.info:hover {

    font-weight:bold;

}

hr.hourly {

    border: none;
    color: #000;
    height: 1px;
    width: 100%

}

</style> </head> <body> below is a active sensor log.<br> One thermistor and one solar cell are in my apartment detecting the amount of heat and the amount of light.<br> <br><font color="blue"><b>thermistor data</b></font><br> <br><font color="red"><b>solar cell data</b></font><br><br> <?

//build link for viewing flipped data // if the query string is flip = 1 then do not include flip in link // else include ?flip=1 if ($_GET['flip'] !="1") {

    $flip = "?flip=1";

} ?> <br> <a href="log.php<?= $flip; ?>">Flip Data</a><br>

<? echo "Number of records: " . mysql_num_rows($results) . "<br><br>";

//loop through the records that were returned from the query you made above while ($row = mysql_fetch_assoc($results)) {

    $currentDay = date("d", strtotime($row['dateTime'])); //get the current day
    $currentHour = date("H",strtotime($row['dateTime'])); //get the current hour

    //place title for new days.
    if ($prevDay != $currentDay) {
        echo "<br><br>" . date("M d, Y", strtotime($row['dateTime'])) . "<br><br>";;
    }

    //place a horizontal line for new hours
    if ($prevHour != $currentHour) {
        echo "<hr class='hourly'>";
    }


    //display the data
    $count=0;
    echo "<li class='thermistor'><a href='#' class='info'>";

    //print a line of  '.' the length of the thermistor value
    while($count<$row['temp']) {
        echo ".";
        $count++;
    }
    //span will include the mouse over information
    echo "<span>" . date("M d,Y H:i:s", strtotime($row['dateTime'])) . "<br> thermistor=". $row['temp'] . "<br>solar=" . $row['solar'] . "</span>";
    echo "</a></li>";


    $count = 0; //reset count for the solar data
    echo "<li class='solar'><a href='#' class='info'>";

      //print a line of  '.' the length of the thermistor value
        while($count<$row['solar']) {
        echo ".";
        $count++;
    }

    //span will include the mouse over information
    echo "<span>" . date("M d,Y H:i:s", strtotime($row['dateTime'])) . "<br> thermistor=". $row['temp'] . "<br>solar=" . $row['solar'] . "</span>";
    echo "</a></li>";

    $prevDay = $currentDay; //save currentday as prevday
    $prevHour = $currentHour; //save current hour as prevhour

} //end of while loop

?> </body> </html>