activee Posted May 20, 2014 Share Posted May 20, 2014 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. 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 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 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 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 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 Link to comment https://forums.phpfreaks.com/topic/288623-sorting-an-upvoting-system/#findComment-1480202 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.