Jump to content

[SOLVED] can't make my member types count appear properly


nomanoma

Recommended Posts

hi:

i have 3 different types of members that i'd like to show their count separately on my site.

mysql version is: 4.1.22

phpmyadmin:2.11.9.4

 

the command i run is:

$count= mysql_query("select * from members WHERE verified=1");

    $rowcount = @mysql_num_rows($count);

 

 

    ?><font size="2" face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>">

    </font><font face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>">   

    <p align="right"><font face="Tahoma" size="2" color="<? echo $fontcolour; ?>"><b>Member Count: <? echo $rowcount; ?><br />

 

this shows the total member count.

what i want is to add under it the exact numbers of every member type to look like this:

 

free members: 100

pro members: 100

Jv members: 100

 

all i was able to do was add this code:

echo mysql_result(mysql_query("SELECT COUNT(*) FROM members WHERE memtype = 'FREE'"),0). " Free members<br>";

 

echo mysql_result(mysql_query("SELECT COUNT(*) FROM members WHERE memtype = 'PRO'"),0). " Pro members<br>";

 

echo mysql_result(mysql_query("SELECT COUNT(*) FROM members WHERE memtype = 'JVPARTNER'"),0). " JV Partners<br>";

 

but that doesn't show under the total member count, it shows far right above! whenever i try to move it or write an html code to make it appear under that total member count, it shows as code and not as it should be.

 

so please i need someone to write me the whole right code so i can use it.

 

thanks

 

 

Link to comment
Share on other sites

<?php
$query = 'SELECT memtype, count(*) as memtype_cnt'
. ' FROM members'
. ' GROUP BY memtype';

$result  = mysql_query($query);
while ($row = mysql_fetch_array($result)) {
    echo $row['memtype'] . ' ' . $row['memtype_cnt'] . '<br />';
}
?>

 

will display:

 

FREE 100

PRO 100

JVPARTNER 100

Link to comment
Share on other sites

ok i used your code that way:

$query = 'SELECT memtype, count(*) as memtype_cnt'

. ' FROM members'

. ' GROUP BY memtype';

 

$result  = mysql_query($query);

while ($row = mysql_fetch_array($result)) {

    echo $row['memtype'] . ' ' . $row['memtype_cnt'] . '<br />';

}

?>

 

 

 

    $count= mysql_query("select * from members WHERE verified=1");

    $rowcount = @mysql_num_rows($count);

 

 

    ?><font size="2" face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>">

    </font><font face="<? echo $fonttype; ?>" color="<? echo $fontcolour; ?>">   

    <p align="right"><font face="Tahoma" size="2" color="<? echo $fontcolour; ?>"><b>Member Count: <? echo $rowcount; ?><br />

 

first: the member types showed on the left above the total member count and whenever i place it under it it shows as code.

 

second: it shows the total member count code instead of it's normal display as in member count: 100

 

so what i need is: to make the members type appear under the total member count on the right (as written in html) and i also want the total member count to still show.

 

can you help?

thanks

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.