listing.inc.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php include 'header.inc.php'; ?>
  2. <div style="float:right;"><input type="button" value="Log out" onclick="location.href='./?logout'"></div>
  3. <p>Welcome to Netsim! If this is your first time playing, we recommend you start from the first level below, and work your way forward.<p>
  4. <?php
  5. $res = $db->query("SELECT * FROM category ORDER BY orderby");
  6. while ($row = $res->fetchArray()) {
  7. echo "<h3 style=\"clear:both;;\">".$row['name']."</h3>\n";
  8. $res2 = $db->query("SELECT * FROM level WHERE category_id = ".$row['id']." ORDER BY orderby");
  9. while ($row2 = $res2->fetchArray()) {
  10. $complete = levelComplete($row2['id']);
  11. echo "<div style=\"float:left;position:relative;border-radius:0 0 10px 10px;border:solid 1px #AAA;margin:10px;padding:5px\">";
  12. echo "<a href=\"./?level=".$row2['id']."\">\n";
  13. echo "\t<img".($complete ? " style=\"opacity:0.3\"" : "")." src=\"includes/thumbs/".(file_exists("includes/thumbs/".$row2['id'].".png") ? $row2['id'] : 0).".png\">\n";
  14. if ($complete) echo "\t<img src=\"includes/thumbs/check.png\" style=\"position:absolute;top:80px;left:70px;\">\n";
  15. echo "</a><br>\n";
  16. echo "<a href=\"./?levels=".$row2['id']."\" style=\"color:#000;text-decoration:none;\">".$row2['name']."</a>\n";
  17. echo "</div>\n";
  18. //echo "[";
  19. //echo levelComplete($row2['id']) ? "X" : "&nbsp;";
  20. //echo "] <a href=\"./?level=".$row2['id']."\">".$row2['name']."</a><br>\n";
  21. }
  22. echo "<div style=\"clear:both;margin-bottom:30px;\"></div>";
  23. }
  24. function levelComplete($l) {
  25. global $db;
  26. $q = $db->query("SELECT * FROM solns WHERE user_id = ".$_SESSION['cs4g_user_id']." AND level_id = $l");
  27. $row = $q->fetchArray();
  28. return $row !== false && $row['completed'] == 1;
  29. }
  30. include 'footer.inc.php';
  31. ?>