Delete specific row in database table

@Valentin_Gjorgoski here is what your code should be like

<?php 
//database connection $dbrequire('includes/config.php'); 

$query='DELETE * FROM studentraspored WHERE ID = ?';
$db->prepare($query)->execute([$_POST['ID']]);

header('location:index.php');
exit();

It is essential to run all your queries this way: to substitute every variable with ? mark in your query, while variable itself have to be moved into execute().
That’s the only proper way as here your SQL will be formatted properly. If you’re learning PDO it would be worth to read this article

@spaceshiptrooper
Actually, if ($_POST) is okay. If this array is empty then there will be little sense in processing it anyway.
As of the row_count, it’s never actually needed at all.

1 Like