Answer the question
In order to leave comments, you need to log in
How to make unique id php + mysql?
In general, what is needed: id, which will be recalculated after deleting one of the lines.
auto_increment doesn't work because the id's go on in order, without recalculation.
How to implement?
I delete like this:
$id = $_GET["del"];
$del = $query = "delete from $table where (id='$id')";
mysql_query($query) or die(mysql_error());
if ( isset($_GET['act']) ) {
$id_user = $_GET['id'];
$sql_delete = "DELETE FROM orders WHERE id_user= $del";
mysql_query($sql_delete);
}
Answer the question
In order to leave comments, you need to log in
what does it mean to count?
Here you have a million records in the table. and deleted 354, 4556, 48880 entries. what id should the new record get?
It can't be done because it's meant to be. If you have 10 entries, deleted No. 5, then No. 6 cannot become number 5 because it receives requests from those who want to see number 6.
In short, delete one apartment in the entrance and shift the rest of the numbers by one and each (residents remain in their apartments, do not move) then call the guests and see what happens ...
Hint: you need to overtake the data from the table to a new table so that the numbers are in order.
describe the situation, something is not very clear, what is the need, maybe you don’t need to edit the code, but just do it differently (correctly), if possible, show tables and relationships (ER diagram)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question