You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.6 KiB

  1. <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  2. <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  3. <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  4. <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  5. <h1>Welcome to "tug of war in the clouds"!</h1>
  6. <p>
  7. Choose and tug a cloud:
  8. </p>
  9. <p>
  10. <?php
  11. include 'config.php';
  12. if (isset($_POST['new_cloud_name']))
  13. {
  14. $sql = "INSERT INTO clouds (name, value, max_value) VALUES ('" . $_POST['new_cloud_name'] . "',0," . $_POST['new_cloud_goal'] . ")";
  15. $pdo->query($sql);
  16. }
  17. $sql = "SELECT * FROM clouds";
  18. foreach ($pdo->query($sql) as $row) {
  19. if (abs(intval($row['value'])) < intval($row['max_value']))
  20. {
  21. echo "<a href='cloud.php?cloud_id=" . $row['cloud_id'] . "'>" . $row['name'] . "</a> (score: " . $row['value'] . ", goal:" . $row['max_value'] . ")<br />";
  22. }
  23. }
  24. ?>
  25. <!-- list -->
  26. </p>
  27. <p>
  28. or form a new cloud:
  29. <form action="" method="post">
  30. Name: <input name="new_cloud_name" value="">
  31. Goal: <input name="new_cloud_goal" value="10">
  32. <input type="submit" value="Create">
  33. </form>
  34. </p>