Jump to content

Auto-Increment issue


Shattered

Recommended Posts

Hey everyone.  This is my first post here so bare with me :)

Im also a newbie when it comes to any PHP programming, but Im getting the hang of it I think.

Anyway onto my issue.

I am creating a page for my work to show an inventory of the computers we have in our lab.  Its all in an Excel format, but only one person can use it at a time, at least edit it.  Its a little inconvenient when there are about 15 or 20 people that want to work with it.

So, with my extensive knowledge here I be.

I got the main portions of it together so far.  I can add a PC to the list, and remove a PC to the list.  And output a total list of everything.  So far so good.

When I try to delete a row though is my problem.  I have it showing the ID column cause I was gonna later use it for editing computers (which I am stuck on by the way).  Well, this ID is the auto-increment number.  Here is the real problem. (Dodged it a bit didn't I?).  When I delete a row from the list, and then add a new PC, the ID number keeps going up instead of taking place of a new number, make sense?

Example:  I have 10 rows.  I delete row 4.  Now I have 9 rows, listed 1-3 and 5-10.  Is there a way so that when I delete a row, that the ID number will change and keep everything numbered correctly?  (IE: Deleting row 4 makes it list 1-9)

Sorry if this is a dodgey post, at work and Im doing about 10 things at once.
Link to comment
https://forums.phpfreaks.com/topic/35247-auto-increment-issue/
Share on other sites

Im a little picky, and it looks tacky to see the numbers jumping around like that.

I wont be the only person using this page, and if it was, I wouldnt care.  Id rather not be asked about it.

When I get to it, for the editing of rows, I thought using the ID to select which computer you would want to update.  Still working on that part though.
Link to comment
https://forums.phpfreaks.com/topic/35247-auto-increment-issue/#findComment-166503
Share on other sites

Are you sure you really want your computer's "ID" to change all the time like that? Ids are usually unique for a reason. Especially if you want to (later on) keep track of past information, even after you "delete" it (as jesirose pointed out). 

If you are simply looking to have it "say" 1-9 after you delete something in the middle, for the sake of your fellow employees, just superficially add it in your loop that lists them, with a $count variable incrementing by 1 on each iteration of your loop, or something.

Link to comment
https://forums.phpfreaks.com/topic/35247-auto-increment-issue/#findComment-166526
Share on other sites

Sorry I got caught up with some things here.

I think really I just might be going about it the wrong way.  I dont really know.  I just wrote something up without really thinking about it and went from there.  (Yes I know I skipped the design process)

For now Im just not going to worry about the ID numbers.  I think for maybe doing a "Update PC" type deal Ill use another field instead, a PC name or service tag perhaps. 

Make it pretty after I get it fully functional.

Speaking of which, should I make another topic for getting help with updating the page, or could I just squeeze it into this thread?
Link to comment
https://forums.phpfreaks.com/topic/35247-auto-increment-issue/#findComment-166567
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.