I have a table with info on different cases. I have set up a page that displays "open" cases that's unsolved. The open cases have a default user assigned, which means it's not dedicated to anyone. It also has a status value which determines if the case is solved. In the open cases page, only the cases with default user and case status "unsolved" are displayed. Another page displays "my cases". This page displays unsolved cases connected to the logged in user. For displaying the open cases I do this:
<?php
if ($result = mysqli_query($link, $sqlasget)) {
if (mysqli_num_rows($result) > 0) {
while ($row = mysqli_fetch_array($result)) {
echo "<div class='divelementlasse' id='" . $row['case_id'] . "'>";
echo "<h3 class='divphh3'>" . $row['kunde_navn'] . "</h3>";
echo "<h5 class='divphh5'>" . $row['case_adresse'] . "</h5>";
echo "<p>" . $row['case_kommentar'] . "</p>";
echo "<form action='" . htmlspecialchars($_SERVER['PHP_SELF']) . "' method='post'><input type='submit' class='tasak' name='" . $row['case_id'] . "' value='Ta sak" . $row['case_id'] . "'></input>";
echo "</div>";
}
mysqli_free_result($result);
} else {
echo "<div class='divelementlasse'>";
echo "<h3 class='divphh3'>Ingen elementer å vise.</h3>";
echo "</div>";
}
} else {
echo "ERROR: Could not be able to execute $sql. " . mysqli_error($link);
}
?>
This works for displaying the cases. The problem I have is the buttons. When a user hits "ta sak" I want to change the user of that specific case, to the logged in user. So basically: When a user hits the submit button for one of the cases displayed, that case is "transferred" to "my cases". I do not want to use Ajax, but if that's the ONLY solution so be it.
$_SESSIONto get the id of the logged in user and add the id to the case so when you submit it would be sumitted for that logged in id$_SESSIONfor displaying cases related to the "my cases" pages, so that's all good :)