activee Posted May 20, 2014 Share Posted May 20, 2014 (edited) Hey I'm trying to do an up voting system kinda like reddit. So I got my table with upvotes and downvotes. The hiccup is when i want to echo all the entries in my table but I want these being sorted by effective votes. So basically if an entry has 250 upvotes and 30 downvotes and the second entry has 250 upvotes and 2 downvotes the second one should be echoed first. I know how to echo all the rows of my table I just don't know how to sort them via effectives votes. I'm not sure how I should proceed. Any help to get started would be welcome. Edited May 20, 2014 by activee Quote Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/ Share on other sites More sharing options...
Barand Posted May 20, 2014 Share Posted May 20, 2014 ORDER BY upvotes, downvotes Quote Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/#findComment-1480155 Share on other sites More sharing options...
activee Posted May 20, 2014 Author Share Posted May 20, 2014 (edited) no, no noI got upvotes in my table and I got downvotes in my table.I don't have effectivevotes in my table. effectivevotes = upvotes - downvotes. I want my rows to be ordered by effectivevotes. if I follow your instruction if I'm not mistaking : one row could have 1000 upvotes and 2000 downvotes and would still be higher than a row which has 1 upvotes and 0 downvotes Edited May 20, 2014 by activee Quote Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/#findComment-1480167 Share on other sites More sharing options...
Barand Posted May 20, 2014 Share Posted May 20, 2014 Must get a new battery for my crystal ball ORDER BY upvotes - downvotes Quote Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/#findComment-1480169 Share on other sites More sharing options...
activee Posted May 20, 2014 Author Share Posted May 20, 2014 thanks I didn't know that was possible Quote Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/#findComment-1480202 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.