row deleting problem - primary key help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zmurf
Forum Newbie
Posts: 10
Joined: Wed Jan 26, 2005 8:15 am
Location: romania
Contact:

row deleting problem - primary key help

Post by zmurf »

I asked here about deleting a row, thanks to u people i found it easy.

But know i have a new problem. my table has an "id"-primary key and autoincrement, when I delete lets say row number 2, the next id after 1 becomes 3.

1- server a-on
2- server b-on <--- delete
3- server c-on

=> 1-server a-on
3-server c-on <----- i want this one to be 2-server c-on
4-server d-on <----- and this one to become 3-server d-on
Last edited by zmurf on Tue Feb 15, 2005 10:57 am, edited 3 times in total.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

now all you need to do is create a form or more forms...

that allow you to select a row... usually a checkbox are a radio button is used for this... and a submit button...

virtually every html tutorial will teach you how to accomplish that.
zmurf
Forum Newbie
Posts: 10
Joined: Wed Jan 26, 2005 8:15 am
Location: romania
Contact:

10x

Post by zmurf »

10x timvw, i solved the problem in my code, but now i need to know how to put those auto increments in order.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

auto_incremented fields are not supposed to be fiddled with.
zmurf
Forum Newbie
Posts: 10
Joined: Wed Jan 26, 2005 8:15 am
Location: romania
Contact:

yup

Post by zmurf »

yes indeed, but look at phpmyadmin, i modified my id from there, so i guess it could be done
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Re: yup

Post by John Cartwright »

zmurf wrote:yes indeed, but look at phpmyadmin, i modified my id from there, so i guess it could be done
As feyd said, it will become very annoiying and glitchy if you decide to alter your auto_incremented field. There is no reason you should have to anyways. Better off re-thinking your logic.
Post Reply