moose-en-a-gant Posted January 12, 2015 Share Posted January 12, 2015 I have this interesting problem, I think I know how to do it. In a java class I took there was a lab on swapping the values of variables and if there were two variables, you needed a third temporary value holder. So this project I'm working on has a row output, currently the individual values are outputted as a concatenated string but ideally they would be independent rows with accompanying buttons. One of those buttons is a ^ symbol, when you press this, ideally the row is moved up in ID putting the previous ID in front or ahead. The problem is that the ID's / rows are not necessarily in sequential order. So, when I recall a set of rows that have random sequential values for example, 2, 5, 27, 41, 43 and those are outputted by themselves, now becoming 0,1,2,3,4 respectively or 1,2,3,4,5 So when I try to move 43 to position 2, that's 4 positions away or 4 clicks of the ^ button. Now how do you deal with that 4 difference and the difference of 41... ? thereby, when the initial set of rows are recalled again, the order is now, 43, 5, 27, 41, 2 Of course the ID I think remains the same but the data is switched... ? yeah I have to draw some pictures, but this isn't a current problem to fix, later on down the road after I update the interface. here is a drawing to explain, I'm more of a visual person Any ideas would be appreciated, otherwise I will post my solution when I come to it. Or I don't figure it out and find one. thanks Quote Link to comment https://forums.phpfreaks.com/topic/293868-temporary-place-holder-incremental-organization/ Share on other sites More sharing options...
QuickOldCar Posted January 12, 2015 Share Posted January 12, 2015 Need to work with arrays? This way you can build associative arrays, sort, sort keys or whatever else need to do with it. Quote Link to comment https://forums.phpfreaks.com/topic/293868-temporary-place-holder-incremental-organization/#findComment-1502657 Share on other sites More sharing options...
moose-en-a-gant Posted January 12, 2015 Author Share Posted January 12, 2015 I don't know... I have one table that users write into. There are generally five fields, although it will increase: ID, username, content, keyphrase, date People can write in random orders so when a specific user pulls up their content, the ID's are off... I don't know if it's pointless for me to re-explain again. So you've got these row ID outputs 2,5,87,93,100,393, and they are pulled by themselves so they could be treated as 1,2,3,4,5,6 Then, when the rows are swapped by the ^ button, they change in order and consequently their ID values change in the table I don't know if I can do that, would I need an empty row to use as a temporary place holder? Quote Link to comment https://forums.phpfreaks.com/topic/293868-temporary-place-holder-incremental-organization/#findComment-1502707 Share on other sites More sharing options...
Barand Posted January 12, 2015 Share Posted January 12, 2015 There are generally five fields, although it will increase: ID, username, content, keyphrase, date People can write in random orders so when a specific user pulls up their content, the ID's are off... That is the reason we use forms rather then one big text area; so the order and type of information can be controlled. Quote Link to comment https://forums.phpfreaks.com/topic/293868-temporary-place-holder-incremental-organization/#findComment-1502715 Share on other sites More sharing options...
moose-en-a-gant Posted January 12, 2015 Author Share Posted January 12, 2015 (edited) What do you mean? The only textarea I use is "content", this accepts any strings, urls, paragraphs, etc... the rest are either Int's or Varchars I have used the string concatenation solution temporarily as it was all that I needed but some suggestions came to mind which I view as a must for the tool to function correctly. Edited January 12, 2015 by moose-en-a-gant Quote Link to comment https://forums.phpfreaks.com/topic/293868-temporary-place-holder-incremental-organization/#findComment-1502719 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.