I'm looking to delete a row in a database so when I click the button it deletes that row. I've looked around and found examples but these relate to having external PHP sheets but I'm looking to include mine on the same sheet. My code is:
if(isset($_GET['deleteId']))
{
$query = mysql_query("DELETE FROM kingswinfordcc_vehicles WHERE vehicleid = '$_GET['deleteId']'");
header("Location: vehicle-table.php");
}
which if I'm correct deletes the row from the specified table and then moves the user to the new page.
Then my table holds a button which I'm currently using as a link, as follows so when clicked links back to the same page
<td> <a href="vehicle-table.php?deleteId=<?php echo $vehicle_row['vehicleid'] ?>">Delete</a></td>
I'm only doing it this way as a senior colleague has told me to. Any advice/help is greatfully appreciated.