User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 391,590 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,668 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 1818 | Replies: 4
Reply
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

need to update each records after record deleted

  #1  
Apr 15th, 2005
need to update each records after record

hi,

Would anyone share with me a code that can be used for this logic.

If i delete from a x records, record u.I need to update each records after record u till record x.the updation need to be carried out for the auto_increment field.

I think of a logic like this.
If need to delete the record,it should take the records after it,issue update query or update and then delete the record mentioned ,insert the updated records to database.

please some one help me by sharing this logic's code...or with a better code.
thanking you in advance i remain

sincerely
hbmarar
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Mar 2004
Posts: 715
Reputation: Phaelax is on a distinguished road 
Rep Power: 6
Solved Threads: 28
Phaelax Phaelax is offline Offline
Master Poster

Re: need to update each records after record deleted

  #2  
Apr 15th, 2005
I'd help, but I have no clue what you just said.
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: need to update each records after record deleted

  #3  
Apr 18th, 2005
well,

i have wriiten a code for addressbook isn which i found a bug very late...I mean i have the following functions for the address book:-
Add,Update,Delete,Search,Showall. now once i have deleted a record the id which is autoincremented remains the same.so the deleted records id is never used again.

like this :
4|Harish|Balakrishnan|hbm@hbm.com|Phone|Pin
5|Balakr|HariKrishnan|bala@bala.com|Phone|pin
6|Harira|Balarishnan|bm@hbm.com|Phone|Pin

now if I delete record with id=5,resulting database view is like this

4|Harish|Balakrishnan|hbm@hbm.com|Phone|Pin
6|Harira|Balarishnan|bm@hbm.com|Phone|Pin
I need to use the id=5 which with the current logic is not utilised.

I think this would give you the need I mentioned in the thread.please help me with a code/function which before deletion updates all the records after the record deleted decrementing all the records after the deleted record id by 1;

Thanking you for the assurance that you could help me and I myself really expecting your favour

I remain
Hari
Reply With Quote  
Join Date: Apr 2005
Posts: 4
Reputation: davespink is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
davespink davespink is offline Offline
Newbie Poster

Re: need to update each records after record deleted

  #4  
Apr 18th, 2005
I'd redesign the logic if I were you. I never rely on auto updated keys for anything other than bookmarking a record.
i.e. I read it, store the auto update key cos I know it's unique, do whatever to the record, then update it using the auto update in the where clause. Better have a good design than patch up a poor one as it will only haunt you later.
Reply With Quote  
Join Date: Apr 2005
Location: Kerala
Posts: 156
Reputation: hbmarar is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
hbmarar's Avatar
hbmarar hbmarar is offline Offline
Junior Poster

Re: need to update each records after record deleted

  #5  
Apr 18th, 2005
Originally Posted by davespink
I'd redesign the logic if I were you. I never rely on auto updated keys for anything other than bookmarking a record.
i.e. I read it, store the auto update key cos I know it's unique, do whatever to the record, then update it using the auto update in the where clause. Better have a good design than patch up a poor one as it will only haunt you later.

hi,

Yes. You said is correct and my brother too say 'this way' that once he is to development there would not be a major re-designing required.'

But I am not him and thus would like to see this code working....

If you have alternative code do please share with me....

Thanking you I remain

Hari
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 11:14 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC