Shattered Posted January 22, 2007 Share Posted January 22, 2007 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. Quote Link to comment Share on other sites More sharing options...
trq Posted January 22, 2007 Share Posted January 22, 2007 Sorry, that is not how auto-incriment works. You should not rely on it being an ordered list of numbers. Quote Link to comment Share on other sites More sharing options...
Shattered Posted January 22, 2007 Author Share Posted January 22, 2007 Then would you have another suggestion/route that I should go? Quote Link to comment Share on other sites More sharing options...
effigy Posted January 22, 2007 Share Posted January 22, 2007 Why do you want to numbers to be consecutive? Quote Link to comment Share on other sites More sharing options...
Shattered Posted January 22, 2007 Author Share Posted January 22, 2007 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. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 22, 2007 Share Posted January 22, 2007 Don't delete rows, just mark a field as deleted, and don't show those. That way the data still exists. Quote Link to comment Share on other sites More sharing options...
.josh Posted January 22, 2007 Share Posted January 22, 2007 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. Quote Link to comment Share on other sites More sharing options...
Shattered Posted January 22, 2007 Author Share Posted January 22, 2007 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.