Please,
I’m having weird error with SQL module.
This is the code:
{exp:query sql="SELECT m.member_id AS member_id, m.screen_name, m.avatar_filename,
SUM(c.diggie_vote_value) AS vote_value, SUM(c.best) AS best,
(SUM(c.diggie_vote_value) + SUM(c.najbolji)*10) AS total
FROM exp_comments c
LEFT JOIN exp_members m ON c.author_id = m.member_id
WHERE c.weblog_id = 3
GROUP BY c.author_id
ORDER BY total DESC" limit="20" paginate="bottom"}
{count}. /images/avatars/{avatar_filename}{member_id}. {screen_name} - G: {vote_value}, N: {best} = {total}
{paginate}
<div class="pagination">Page {current_page} from {total_pages} {pagination_links}</div>
{/paginate}
{/exp:query}Without pagination this works, but LIMIT doesn’t work?! I’m getting 500 results by default?!
2. If I add pagination links, then I’m getting error:
MySQL ERROR:
Error Number: 1054
Description: Unknown column 'total' in 'order clause'
Query: SELECT COUNT(*) AS count FROM exp_comments c LEFT JOIN exp_members m ON c.author_id = m.member_id WHERE c.weblog_id = 3 GROUP BY c.author_id ORDER BY total DESCAs You can see there is no fields in SQL that I’m selecting?!
PS I already made this with PHP but I dont know how to use pagination with PHP in templates?
Could someone help me with this one
Thanks