If any of you are interested - this code works. It is by no means fool proof and I think the more experienced programmers would dispare if they saw that I was using this but here goes;
$query = "SELECT * FROM tenerpiso_alquiler WHERE userid = '$userid' AND code = '$codecom'";
//Retrieve data from database.
$result = mysql_query($query); // run the query
if (mysql_num_rows($result) != 0)
{
$data = mysql_fetch_array($result); // get results into $data
$query = "DELETE FROM tenerpiso_alquiler WHERE userid = '$userid' AND code = '$codecom'";
// Delete the image info from the database
$result = mysql_query($query); //run the query
print "<p><b> Su propiedad ha sido borrada </b></p>\n";
unlink("fotos_pisos_alquiler/" . $data[fotos]);
// delete the file
}
else { print "<p><b> Lo siento su codico es incorecto </b></p>\n"; }
Now - I have a small question:
If I display the results of a search out in a table with a while loop - how do I pass a variable acrossto another php page? I do this with variables used for the search but I don't know how to do this for variables taken from the database.
I want for people who have sold their property to be able to delete it so they can find thier property doing a normal search and next to each one there is a "delete" button which is basically alink to the code shown above. However I would prefer it if they didn't have to remember their user id so is there any way of passing this across?
while ($row = mysql_fetch_assoc ($result))
echo "<div><a href=delete.php?userid2=$userid'>DELETE ENTRY</a>
Something like this but using variables from the database.
Thanks a lot.