function addLooser($studentid, $blameid) { global $servername, $username, $password, $db; if (isWinner($studentid, $blameid)) { removeWinner($studentid, $blameid); } else { if (isLooser($studentid, $blameid)) { return null; } } $conn = mysqli_connect($servername, $username, $password, $db); $query = "INSERT INTO Lost (studentid, blameid) VALUES ('" . $studentid . "', '" . $blameid . "');"; $result = $conn->query($query); $conn->close(); return $result; }
</ul> <?php echo "<a href='add_blamer.php?blameid=" . $blameid . "'>Tilføj person</a>"; ?> <h2>Klandret</h2> <ul> <?php if (sizeof($blamed) > 0) { foreach ($blamed as $student) { $style = ""; if (isWinner($student[0], $blameid)) { $style = "style='color:green;'"; } else { if (isLooser($student[0], $blameid)) { $style = "style='color:red;'"; } } echo "<li " . $style . ">" . $student[1] . " - <a href='view_blame.php?blameid=" . $blameid . "&deleteblamed=" . $student[0] . "'>X</a>" . " - <a href='view_blame.php?blameid=" . $blameid . "&markwinner=" . $student[0] . "'>W</a>" . " - <a href='view_blame.php?blameid=" . $blameid . "&marklooser=" . $student[0] . "'>L</a>" . " - <a href='view_blame.php?blameid=" . $blameid . "&markneutral=" . $student[0] . "'>N</a></li>"; } } else { echo "Hov, der er ingen som er blevet klandret :("; } ?> </ul> <?php echo "<a href='add_blamed.php?blameid=" . $blameid . "'>Tilføj person</a>"; ?> </body>