monkeytooth Posted April 27, 2010 Share Posted April 27, 2010 Alright I think ive done lost my train of thought somewhere... I have a table for the sake of ease ill say its 3 columns. an ID that has nothing to do with anything but is there just cause I will one day need to reference it. and 2 other columns my member's ID tied to a numeric value. Each numeric value represents the way a list will be sorted, the order it will be sorted in. Unfortunately for the life of me I seem to be having this issue with my mind where I cant think proper and the means of finding the highest number to be sorted is evading me. One I need this value so I can run it through a foreach to print out the bloody things on the screen. But next if someone goes and adds something to there list I need to figure out what the highest sort value is so I can add plus one to it. Alternatively to the concept of adding. I know my members are going to want to delete stuff from there list from time to time. So I guess this idea coming to mind would make this post a 2 part question.. Other than finding the highest value and adding 1 to it, I guess to prevent conflict if someone deletes one I need to resort those values. Can anyone suggest how I might do that as well. As always Im not looking for anyone to write me a script, or anything.. just please at the least if you know the answer throw me a bone, give me a link to something I can read up on if you dont want to answer, or something :-) Link to comment https://forums.phpfreaks.com/topic/199879-mysql-next-highest-value/ Share on other sites More sharing options...
trq Posted April 27, 2010 Share Posted April 27, 2010 Take a look at the MAX() function. Link to comment https://forums.phpfreaks.com/topic/199879-mysql-next-highest-value/#findComment-1049138 Share on other sites More sharing options...
monkeytooth Posted April 27, 2010 Author Share Posted April 27, 2010 Playing around with that now, thank you. I do have a question though. By Default I set all things added through the other area's to 0 as how the list should layout. To mark it as uncategorized, needing a category. Which technically is irrelevant to the actual listing its just how Ive worked it to tag it as a new column in a users list. So that said, if all the values are 0 it would return 0? and just pull the query as i dunno a query done without the max() as part of it. In other words im not going to error myself out am i, and If I am can you think of any work arounds? Link to comment https://forums.phpfreaks.com/topic/199879-mysql-next-highest-value/#findComment-1049153 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.