I've been working on a project for school but for some time now i got stuck. So we need to make a management system for the staff and guests of a simulated hotel, this is pretty much fun but the problem is:
When i try to update a value in my database, it doesn't work, here the UPDATE part of the code:
if (!empty ($_GET['id']))
{$id = $_GET['id'];
$query = "SELECT * FROM gast WHERE id=$id";
$result = mysql_query($query);
if (!$result)
{$message .= "Error msg<br>";}
$aantal = mysql_num_rows($result);
if ($aantal==1)
{$row = mysql_fetch_array($result);
$row['actief'];
$actief = $row['actief'];
if ($aantal==1)
{$query = "UPDATE gast SET actief= 1 WHERE id=$id";
mysql_query($query);
else if ($actief == 1){
$query = "UPDATE gast SET actief= 0 WHERE id=$id";
$result = mysql_query($query);
So what i am trying to create here, is a "toggle" to give a value in my database (called actief). All i got it to do till now is to actually send the value $id within the url, but the rest of the idea is just not working. Now the chance of me making just a stupid mistake is pretty big since i haven't worked with php all that long.
Anyways below you will find the code that sends the ID value to associate the action with the right guest account.
while ($row = mysql_fetch_array($result)){
$actief = $row['actief'];
$id = $row['id'];
if ($actief==1){
echo
'<tr><td>' . $row['id'] .
'</td><td>' . $row['voornaam'] .
'</td><td>' . $row['tussenvoegsel'] .
'</td><td>' . $row['achternaam'] .
'</td><td>' . $row['tel'] .
'</td><td>' . $row['mobiel'] .
'</td><td>' . $row['nationaliteit'] .
'</td><td>' . $row['kamer'] .
'</td><td>' . $row['email'] .
'</td><td>' . "<a href='list_users.php?id=$id'><font color='lime'>" . "<i class='fa fa-thumbs-up'></i>" . "</font>" .
'</td></tr>';
}
else{
$actief = $row['actief'];
$id = $row['id'];
echo
'<tr><td>' . $row['id'] .
'</td><td>' . $row['voornaam'] .
'</td><td>' . $row['tussenvoegsel'] .
'</td><td>' . $row['achternaam'] .
'</td><td>' . $row['tel'] .
'</td><td>' . $row['mobiel'] .
'</td><td>' . $row['nationaliteit'] .
'</td><td>' . $row['kamer'] .
'</td><td>' . $row['email'] .
'</td><td>' . "<a href='list_users.php?id=$id'><font color='red'>" . "<i class='fa fa-thumbs-o-up'></i>" . "</font>" . '</a>' .
'</td></tr>';
}
}
$message .= '</table><br>';
}
?>
Right so here is a picture of the layout (ain't really important but you never know).
So whenever i click on the Thumbs up icon, the page will be reloaded, and the url will change to what it should be, nothing more, nothing less is happening here. If anyone has an idea, please let me know!
Greetings,
Pimmy