Hello, I'm in a project where the order of the id's is quite important for the final result, but when I remove a line from the table, there's an empty id left over ... Ex:
IfIdeleteid2itwilllooklikethis...
IwantthecodeafterdeletingittochangeallIDs...Ihaveremovedtheself-incrementsothatIcanmodifybutnotwithmycodewhere$mate=table_name;
<?phpinclude"default.php";
if (isset($_GET['mat']) && isset($_GET['id'])) {
$mat = $_GET['mat'];
$id = $_GET['id'];
include"../ligacao.php";
$query = mysqli_query($conexao, "SELECT * FROM ".$mate);
$linhas = mysqli_num_rows($query);
if ($linhas == $id) {
mysqli_query($conexao, "DELETE FROM ".$mate." WHERE id = '$id'");
} elseif ($id < $linhas) {
mysqli_query($conexao, "DELETE FROM ".$mate." WHERE id = '$id'");
$idn = 1;
while ($idn > $linhas) {
mysqli_query($conexao, "UPDATE ".$mate." SET id = '$idn'");
$idn ++;
}
}
} ?>
The result is just the deletion of the line without changing the id's of the others.
What do I do?