![]() |
Sort "myadopts" page
Is there a way to let users sort their adoptables into the order they want?
|
anyone? =( My members are requesting this and I've no idea how to implement it.
|
Could you be more specific?
In what order do they actually want? By the total clicks? levels? names? ascending or descending? Or something more customizable like, they have full control which one is the first, second, third, and so on regardless of the adoptables' stats? |
More customizable where they can sort which is first,second etc, regardless of the stats =p The other I could do but I don't have any idea how to make it so they can sort them and save the order.
|
You'll need to create a new table for that
I'm thinking the table would be something like this ----------------------------------- |adoptable_id|sorting_number| ----------------------------------- |_________1|____________2| |_________2|____________3| |_________7|____________1| |_________4|____________1| ... And then when you're fetching the adoptables from the owned_adoptables table, join it with the other table above and order the rows by the sorting_number field. |
Ok, how would I go about allowing them to actually sort them... and how to join the tables? I've no idea where to start and can follow code but I'm not advanced by any means =p
|
To allow users to sort their adoptables, you can create a page where it lists all their own adoptables and put a textbox next to each adoptable for them to input the sorting number.
The JOIN query would probably look like this SELECT * FROM adopts_owned_adoptables JOIN adopts_sorting_adoptables ON adoptable_id = aid ORDER BY sorting_number ASC; I think that should do it (for the query part) |
This is great, I've been dying for something like this for ages! I'll be trying it out soon too after straightening out some other little things and see if it works for me. :)
|
Got it working thanks to an awesome friend. Now my next issue.
Is it possible to give my users a link for other people to see the adoptables they own? EDIT: nm =p friend is doing that as well.. I luuuv this guy! |
o.o Where did you get this friend and can I get one? :D
|
I'm selfish and don't like to share ;)
|
I know this is an old post (like a REALLY old one...) but how would I let users sort their pets? Through a preset list. I've been attempting to work it out but I don't have a good enough grasp of PHP... I can get the dropdown list with the button to show up but I don't know how to make it actually send the info to sort the pets that way..
I'd like them to be able to sort their pets by clicks, level, gender, name, class, and birthday (date adopted, which I have stored in the database as birthday in the format 'June 11th, 2017'). Any help would be much, MUCH, appreciated.. XD Once I see the code I'll know how to add more to it, probably, it's just having no idea where to start... |
I've haven't tried it, but I'm assuming this can be done by storing the user's choice somewhere and changing the sort order based on that. So in myadopts.php, there's this line:
PHP Code:
PHP Code:
|
Thanks! I'll try it out tomorrow because I'm probably too tired to make sense of anything XD
|
Hmm it doesn't like the elseif parts o.O It basically ignores them and uses the last 'if' statement regardless of what $sort is set as. I also tried making them all 'if' statements just in case but then it just uses the last one as the default, regardless of what is input in the database... I also tried using them in the view file (just as a test XD) and it obviously didn't work lol XD
PHP Code:
|
I decided to play around with it and I got it working! The refresh is a bit strange, but it works well enough. Otherwise users would have to click on the page link again to see the changes.
For the column in phpMyAdmin, you're going to have to set the default 'as defined' to one of the choices or else you'll get an error. PHP Code:
PHP Code:
I might add this to the tutorials (or mods) section since it seems to be in high demand. |
Awesome! Thanks so much! And people would love it as a mod XD
Also, for the redirect, couldn't you use this instead? PHP Code:
And how would I get the button on the same line as the drop down box? It's for purely aesthetic reasons but I have the text as 'Sort by clicks', 'Sort by [whatever]', etc and want the button next to it. Thanks for your help :3 |
I tried to do it myself, but couldn't figure it out. You can probably do it manually through css with a div element and positioning it next to the dropdown box, but that could lead to issues depending on the user's window size.
EDIT: I can't seem to get the refresh to work that way on my end, I just get an error: Quote:
|
Okay thanks anyway! ^_^ I'm going to give it a shot!
And maybe try PHP Code:
All it would mean is you'd have to manually change the link if you change domains :ooo: |
Still won't work. I'll just stick with what I had xD
|
OK XD Maybe you have something in your header that is preventing it XD Do you have a redirect already in your header?
|
I don't have anything in my header as far as I know. Where did you put that line of code, before $mysidia? (directly underneath public function index). I tried putting it both there and in the same spot as the existing redirect; commenting out the current one of course.
EDIT: Putting it above $mysidia doesn't give a white page error, with the warning still appears in the corner and I have to press the button twice for it to work. |
Well this is where I have it (using your piece of code in myadoptsview)
PHP Code:
EDIT: There might be an error appearing for me but in my php.ini file of WAMP I have errors turned off for things like that. The orange ones appear but the ones that sometimes pop up in the top don't appear anymore. Kyttias did a tutorial for it. I think it was her anyway... And I also have them turned off on my live site (I develop on WAMP and then test it live, just to make sure it works every so often) |
Okay, I think it is my browser! I went on Foodbabs and tried it out, and it works perfectly on your site as well as mine. I use Firefox
|
All times are GMT -5. The time now is 07:28 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.