jeudi 16 avril 2015

Delete record on database through PHP button

I'm trying to add a delete button on a table row, once the user clicks it, I want it to delete the record on the mysql database and therefore, not show on the table. My problem is when I click the delete button, I get a connection error! message, here's my php code:



<?php

$id = $_GET['id'];


$dbc = mysqli_connect('localhost','user','pass','db') or die('Connection error!');



$query = "DELETE FROM table WHERE id = '$id'";
mysqli_query($dbc, $query) or die('Database error!');
\header('location:datapull.php');

?>


thanks for any help in advance...


Aucun commentaire:

Enregistrer un commentaire