nbbcj Posted May 15, 2012 Share Posted May 15, 2012 how can i have 2 AUTO_INCREMENT colloums ? i need my id column and my position column to Auto increment. i cant use the id column to set my position as i need to change the val and as i no u cant change ur prim key auto increment column ???? so any forts how i can get a drop down list box to show the content of column `position` (in format 1,2,3,4,5,6,7ect ) and auto increment when adding a new project. my idea when adding is to get the form page to read the bottom of the `position` column for the number and then add one and set that val to a read only text field on the project add page. is there an easy or better way to do this and how would one go about doing this ??? as im a noobie but getting there how-tos or code samples will help a lot people and im wanting to learn as well so any good php tutorial sites send them ,my way thanks Quote Link to comment Share on other sites More sharing options...
requinix Posted May 15, 2012 Share Posted May 15, 2012 ...and as i no u cant change ur prim key auto increment column ???? And that's where my brain stopped reading your post. What's this "position" column for? Quote Link to comment Share on other sites More sharing options...
nbbcj Posted May 15, 2012 Author Share Posted May 15, 2012 It's to set the order of displaying my projects on the work page its so project 2 can be shown 1st or 5th or last Quote Link to comment Share on other sites More sharing options...
The Letter E Posted May 15, 2012 Share Posted May 15, 2012 It's to set the order of displaying my projects on the work page its so project 2 can be shown 1st or 5th or last Have you considered making a new table `display_order` that just has a primary_key id and a project_id field? Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 15, 2012 Share Posted May 15, 2012 Or just have it as a column, and when you insert one, select the max current value and add one. Quote Link to comment Share on other sites More sharing options...
rythemton Posted May 16, 2012 Share Posted May 16, 2012 When I need to be able to change the order, I just use the primary ID as a default sorting, that way the value for order can be the same without causing issues: $queryorder = 'ORDER BY order ASC, id DESC'; // this defaults to new items first compared to other new items $queryorder = 'ORDER BY order ASC, id ASC'; // this defaults to new items last compared to other new items This also allows me to use larger numbers for manipulation, in case I want to slip something between two items later on without changing the order value of every item. Just another option. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 16, 2012 Share Posted May 16, 2012 In your example query there, you'll need to put backticks around order as it's reserved. Quote Link to comment Share on other sites More sharing options...
rythemton Posted May 16, 2012 Share Posted May 16, 2012 In your example query there, you'll need to put backticks around order as it's reserved. You are correct. I hadn't really thought about that, though. I was just trying to give sample code to try to explain my method. Quote Link to comment Share on other sites More sharing options...
Jessica Posted May 16, 2012 Share Posted May 16, 2012 In your example query there, you'll need to put backticks around order as it's reserved. You are correct. I hadn't really thought about that, though. I was just trying to give sample code to try to explain my method. Oh I know I just wanted to point it out as it's a problem I used to have all the time, using column names like order, desc, etc and then having errors. Quote Link to comment Share on other sites More sharing options...
nbbcj Posted May 21, 2012 Author Share Posted May 21, 2012 hay all thanks for you input iv moved on now and have a other problem lol can only c 2 more problems till this project is done thanks again 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.