0

I am creating a summary page that shows the number of members in each member group.

I tried the following but it only displays 1 as the result and there are 25 members in this group:

{exp:query sql="SELECT count(*) as active_members from exp_members where group_id=9 "}
    {count}
{/exp:query}

What is the correct syntax for this?

Thanks.

  • use {active_members} instead of {count} – Jim Wyse Jun 5 '13 at 18:03
2

You have a conflict of names of variables. "count" is a reserved name.

On all modules of EECMS, the current item number of a loop is parsed on the variable {count}, starting on 1. If you code a query that returns, let's say, 5 rows, your result would be "12345".

Your query returns just one row. The loop will be executed once and returns "1". Of course, you just need one row. You are already using another name. So use it:

{exp:query sql="SELECT count(*) as active_members from exp_members where group_id=9 "}
    {active_members}
{/exp:query}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.