Hello I am a little stuck on this problem can anyone lend a hand. I have a table which has a column with positions with which they are sorted and what I am trying to do is that when the delete button is clicked for one row the row's which have a position value higher than the one that got deleted to get decremented. As in this
// 1
// 2 //now we delete this
// 3
// 4
// and this get's updated with this
// 1
// 2
// 3
<?php
require_once('connect.php');
$name = get_option('selectedSlide');
$position = get_option('selectedSlideId');
try{
global $db;
if(!get_option('selectedSlide')){
$error.="No slide selected.";
echo $error; die;
}
else{
$inserts = $db->prepare("DELETE FROM slider_images WHERE slider_image_name = :names");
$inserts->bindParam(':names', $name);
$inserts->execute();
$incrementAllBehindDeleted = $db->prepare("SELECT slider_image_position FROM slider_images WHERE slider_image_position>:position");
$incrementAllBehindDeleted->bindParam(':position', $position);
$incrementAllBehindDeleted->execute();
die;
}
}
catch(Exception $e){
echo $e->getMessage();
exit;
}
?>