nomanoma Posted April 27, 2009 Share Posted April 27, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/155861-solved-cant-make-my-member-types-count-appear-properly/ Share on other sites More sharing options...
ignace Posted April 27, 2009 Share Posted April 27, 2009 <?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 Quote Link to comment https://forums.phpfreaks.com/topic/155861-solved-cant-make-my-member-types-count-appear-properly/#findComment-820554 Share on other sites More sharing options...
nomanoma Posted April 28, 2009 Author Share Posted April 28, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/155861-solved-cant-make-my-member-types-count-appear-properly/#findComment-820793 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.