Solved

o.k i have a problem, when i delet something from a table its idea number never comes back

Posted on 2008-06-09
8
220 Views
Last Modified: 2010-04-21
o.k lets say i have a table named place1
and it have

id  -   place
1  -    idms
2  -    sds
3  -   dfdf
4 -    dffsf

and lets say i delet id number 4
and i insert onther field
dsfef
so now the table looks like that

id  -   place
1  -    idms
2  -    sds
3  -   dfdf
5 -    dsfef

so where number 4 went?

i want it
0
Comment
Question by:mgtm3
8 Comments
 
LVL 9

Expert Comment

by:Rob Siklos
ID: 21746358
If you want it, then don't delete it!
0
 
LVL 9

Accepted Solution

by:
michofreiha earned 350 total points
ID: 21746387
In order to do that you should not make the id field autonumber...Put it as a number and the value of each new filed that you enter should be the greater value of id+1...This is the only solution
0
 

Author Comment

by:mgtm3
ID: 21746430
how do i do that michofreha?
0
 
LVL 9

Expert Comment

by:michofreiha
ID: 21746484
1-change id type from autonumber to number or int and put it unique or set it as primary key for performance
2-Select max(id) from table
3-$var=max(id)+1
4-insert into table(id,place) values($var,'dsfef')

If it you don't know how to make it work I can build the complete code for you
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

Author Comment

by:mgtm3
ID: 21746574
thank uuuuuu
0
 
LVL 9

Expert Comment

by:michofreiha
ID: 21746584
did it work?
0
 
LVL 29

Assisted Solution

by:fibo
fibo earned 150 total points
ID: 21746629
The point is that not reusing deleted records IDs is useful in certain circumstances: that's why, if the field is "autoincrement" previous "free" values are not reused
Autoincrement does guarantee that every new record as a unique ID, which i s also unique "over time".

In most situations you don't need to worry for holes and "missing numbers": to make it short, it does not cost a cent!

So, if these homes are really a nuisance, spend some time to turn around them: the suggested solutions will be helpful for that; if they are not a nuisance... let them happen as they will!
0
 

Author Closing Comment

by:mgtm3
ID: 31465546
thankss
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now