I have a Mysql table in a database called 'favourites' which holds member (student) favourites of other members (teachers). The table consists of 3 columns - autonum (unique identifier) studentid (unique identifier for students in a seperate table) and teacherid (unique identifier for teachers in a teaching table).
I have a page where users can log into their favourites page, and the page displays details of all the users' favourite teacher profiles. Each profile on it has a button called 'remove from favourites'. What I am trying to do is allow the user to press this button and the favourites' autonum id associated with the profile would be deleted.
I have tried the following code which I hope will alllow the logged in user to remove from his/her favourites:
$sql = "DELETE FROM favourites WHERE studentid = %s"
This line is activated by a button in a form, shown below. My guess was to use an insert behaviour to delete the row. My reasoning behind this was to do with me using the insert behaviour button to insert data. I'm guessing this might not be correct?
])) && ($_POST["MM_insert"] == "favourites"))
$sql = "DELETE FROM favourites WHERE studentid = %s";
$result = mysql_query($sql);
Anyway, thanks for reading this, and please let me know if you need more info.
<form id="form2" name="form2" method="post" action=""> <img src="../newsearch/mail.gif" alt="Email Teacher" width="50" height="45" />
<input name="removefavs" type="image" id="removefavs" src="../newsearch/removefavourites.gif" /><br />
<input type="hidden" name="autonum" id="autonum" value="<?php echo $row_m['autonumber'];?>" >
<input type="hidden" name="MM_insert" value="favourites" />