desithugg Posted April 21, 2006 Share Posted April 21, 2006 well i need a query that #'s a members products ion order from 1-2-3....my tables look like this[code]Members:Username email password____________________________saad -------- -----------darkness -------- -----------Products:Product slot id owner___________________________........ 1 .. saad........ 3 .. saad......... 9 .. saad........ 1 .. darkness[/code]what i need to do is update the table so all the products owned by 'saad' are # 1-2-3... in numerical order in the row 'slot' i cant use auto_incretement becaue i only want to # products owned by'saad' and for the other user his products will also start from 1i can get them to insert by using slot=slot + 1but the problem is sometimes they get ot of place and some #'s are skipped so if any1 can help me with that id appreciate it alot Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/ Share on other sites More sharing options...
fenway Posted April 21, 2006 Share Posted April 21, 2006 Well, you know that you can have a auto-increment that is part of a multi-colum index, right? This allows you to do exactly what you're trying to achieve: ordered groups. Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29233 Share on other sites More sharing options...
desithugg Posted April 21, 2006 Author Share Posted April 21, 2006 [!--quoteo(post=367089:date=Apr 20 2006, 11:26 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 20 2006, 11:26 PM) [snapback]367089[/snapback][/div][div class=\'quotemain\'][!--quotec--]Well, you know that you can have a auto-increment that is part of a multi-colum index, right? This allows you to do exactly what you're trying to achieve: ordered groups.[/quote]umm not sure how to set that up can you maybe detail a little bit and will it work if like the slots get mixed up the person can just click a link that executed the query and they get reset? Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29422 Share on other sites More sharing options...
fenway Posted April 21, 2006 Share Posted April 21, 2006 Take a look [a href=\"http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html\" target=\"_blank\"]here[/a] -- this will auto-number. Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29429 Share on other sites More sharing options...
desithugg Posted April 21, 2006 Author Share Posted April 21, 2006 [!--quoteo(post=367293:date=Apr 21 2006, 04:08 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 21 2006, 04:08 PM) [snapback]367293[/snapback][/div][div class=\'quotemain\'][!--quotec--]Take a look [a href=\"http://dev.mysql.com/doc/refman/5.0/en/example-auto-increment.html\" target=\"_blank\"]here[/a] -- this will auto-number.[/quote]yea i saw that i know that part but what if the product is exchanged with another user and the slots stay the same how would i do it so it renumbers it self according to the users slots already used Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29501 Share on other sites More sharing options...
fenway Posted April 22, 2006 Share Posted April 22, 2006 Yeah, that won't happen on it's own. I must ask why you need to store this slot number -- are you actually using this as some sort of sortorder? If so, they don't have to be sequential, they just have to be larger than the previous one. Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29554 Share on other sites More sharing options...
desithugg Posted April 22, 2006 Author Share Posted April 22, 2006 [!--quoteo(post=367418:date=Apr 22 2006, 02:09 AM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 22 2006, 02:09 AM) [snapback]367418[/snapback][/div][div class=\'quotemain\'][!--quotec--]Yeah, that won't happen on it's own. I must ask why you need to store this slot number -- are you actually using this as some sort of sortorder? If so, they don't have to be sequential, they just have to be larger than the previous one.[/quote]umm no lol im making my own rpg which kinda uses the same concept but i need slots so they show in order and people can do stuff with them and if they exhange items/product the slot #s reoder for the person starting from one and i can't use auto_incretement because im already using it for ID and i can only have it once in a table i thinkany ways i was looking for something more script wisethat counts the users items/products and than #'s the slots you probably wont get what i mean but try checking out the website you might get what i mean[a href=\"http://Http://tpfmail.byethost32.com\" target=\"_blank\"]Http://tpfmail.byethost32.com[/a]login info:username:guestpassword:guestumm and i have 1 more question but i prefere talkiing using MSN IM if you do have an account plzz. add me pakiboi44@hotmail.com Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29612 Share on other sites More sharing options...
fenway Posted April 22, 2006 Share Posted April 22, 2006 Let's keep the discussion to the forums so other can contribute.All I meant was that if you're generating a sequence, you can do this "on the way out" -- no need to store it and maintain it constantly in the DB. However, if this is a "sortorder", where you're showing a list that the user can sort, and you want to maintain this order across "sessions", then you will need to store it. Though if this is the case, you'd be saving it every time anyway, and you wouldn't have a problem.Does this make sense? Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29623 Share on other sites More sharing options...
desithugg Posted April 22, 2006 Author Share Posted April 22, 2006 [!--quoteo(post=367489:date=Apr 22 2006, 01:18 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 22 2006, 01:18 PM) [snapback]367489[/snapback][/div][div class=\'quotemain\'][!--quotec--]Let's keep the discussion to the forums so other can contribute.All I meant was that if you're generating a sequence, you can do this "on the way out" -- no need to store it and maintain it constantly in the DB. However, if this is a "sortorder", where you're showing a list that the user can sort, and you want to maintain this order across "sessions", then you will need to store it. Though if this is the case, you'd be saving it every time anyway, and you wouldn't have a problem.Does this make sense?[/quote]umm makes sense but this is whats happening right nowAll creatures have slotsyou can carry a max of 6 at a timethe 6 you creatures with slots(1,2,3,4,5,6)But than you can change creatures which you want to carry i have made a query for that which just switches the slotsbut than there is trading you can trade your creatures for others so this is where it gets messed up when u trade the slots are not in order anymore so you're data doesnt get stored properly and cant be viewed properlyso what i was looking for is something that willafter trading renumber all of the users creatures from 1-(total creatures)( i am using creatures to make it sound like what im using it for) Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29631 Share on other sites More sharing options...
fenway Posted April 22, 2006 Share Posted April 22, 2006 I understand. You can definitely issue a query that will renumber them; I guess my question is why you are numbering them to begin with. You can enforce for maximum of 6 slots in your app logic -- why have the slot number stored at all? Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29634 Share on other sites More sharing options...
desithugg Posted April 22, 2006 Author Share Posted April 22, 2006 [!--quoteo(post=367500:date=Apr 22 2006, 02:13 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 22 2006, 02:13 PM) [snapback]367500[/snapback][/div][div class=\'quotemain\'][!--quotec--]I understand. You can definitely issue a query that will renumber them; I guess my question is why you are numbering them to begin with. You can enforce for maximum of 6 slots in your app logic -- why have the slot number stored at all?[/quote]because users can have alot of creatures like 1000 and if they want to change the carried ones they can switch the slots and there is some other stuff they will need them for like battle i can't explain everything lol Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29638 Share on other sites More sharing options...
fenway Posted April 22, 2006 Share Posted April 22, 2006 Still... you can use a flag to mark the ones that are currently "active", instead of playing this renumbering game. Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29660 Share on other sites More sharing options...
desithugg Posted April 22, 2006 Author Share Posted April 22, 2006 [!--quoteo(post=367527:date=Apr 22 2006, 06:01 PM:name=fenway)--][div class=\'quotetop\']QUOTE(fenway @ Apr 22 2006, 06:01 PM) [snapback]367527[/snapback][/div][div class=\'quotemain\'][!--quotec--]Still... you can use a flag to mark the ones that are currently "active", instead of playing this renumbering game.[/quote]umm true but accept you dont recieve all you're creatures at signup you have to catch so it wouldnt work with marking using flags so id much rather prefere renumbering do u have any idea how i can acheieve this?o and im having trouble with making a query that fetches a row and if the row doesnt exsist it echos "none" it's used for a picture so if the result is not found it shows a default picture named none and if it is found it shows the result Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29667 Share on other sites More sharing options...
fenway Posted April 23, 2006 Share Posted April 23, 2006 You can do this with a few user variables and an UPDATE statement. As far as handing "missing" pictures, a proper LEFT JOIN will return nulls for missing records, and your app should be able to handle this quite easily. Quote Link to comment https://forums.phpfreaks.com/topic/8009-ing-in-order-on-click/#findComment-29767 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.