I need some help with PHP and SQL. Have looked for help in older questions and answers here but can't find anyting like my problem. I'm doing a webbsite where you can post notes in different subjects (Work, Home, School, and so on). After every note that being selected from my database I have a delete button that deletes the selected note.
Now I want to add a change/update button next to the delete button. When pressing the update button I want to be redirected to another page (update.php for example) where that original note is, ready to type in something new or change the note. Then pressing another update button that sends and replace the note at my database table. I have no idea how to to that and would be so grateful for all the help I can get.
This is my code that shows all the current posts for the subject work and where the update button should be next to the delete button.
<?php
if(isset($_POST['delete'])){
$id = $_POST['delete_rec_id'];
$query = "DELETE FROM notes WHERE id=$id";
$result = mysql_query($query);
}
$query = "SELECT * FROM notes WHERE subject='Work' order by id desc";
$result = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
$id = $row['id'];
$subject = $row['subject'];
$date = $row['date'];
$note = $row['note'];
print "<p><strong>$subject</strong> ($id), $date </p>";
print "<p> $note </p>";
?>
//delete button starts here here
<form id="delete" method="post" action="">
<input type="hidden" name="delete_rec_id" value="<?php print $id; ?>"/>
<input type="submit" name="delete" value="Delete!"/>
</form>
//THIS IS WHERE THE DELETE BUTTON SHOULD BE
<?php
}
?>
So grateful for any help i can get :)