<?
    require 'dbconnect.inc';
    $ts=time();
    // Request the ID and expiry of all the magnets
    $result = mysql_query(
                "SELECT Expires, Magnet, Xpos, Ypos, Symbol, MAX(MovedAt) AS LastMove".
                 "FROM tblMagnet, tblMoves ".
                 "WHERE tblMagnet.Expires>FROM_UNIXTIME($ts) ".
                 "AND tblMoves.MovedAt=LastMove";
                 
    if (!$result) {
      echo("<P>Error performing query: " .
           mysql_error() . "</P>");
      exit();
    }
    echo("<p><u>Latest</u></p>");
    while ( $row = mysql_fetch_array($result) ) {
      $magnet = $row["Magnet"];
      $xpos = $row["Xpos"];
      $ypos = $row["Ypos"];
      $symbol = $row["Symbol"];
      echo("<P>$magnet - $xpos - $ypos - $symbol</P>");

    }
?>

