porko2004 Posted December 30, 2008 Share Posted December 30, 2008 im making a thing which gets number of peopel from a database. ill show u what im trying to do. <?php require('config.php'); $sql = "SELECT g.name as Name , s.syn_id as MembersCount FROM cq_syndicate as g LEFT JOIN cq_synattr as s ON (g.id = s.syn_id) ORDER BY s.syn_id DESC LIMIT 0,15 "; $result = @mysql_query($sql) or die(mysql_error()); echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center> Guild Name </center></font></th> <th><FONT COLOR=red> Amount Of Members </th> </tr></font>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td bgcolor=''><center>"; echo $row['Name']; echo "</td><td bgcolor=''><center>"; echo $row['MembersCount']; echo "</td></tr>"; } ?> This is it. I got team names in a table called cq_syndicate. And all members names are in a table called cq_synattr. They team table has an id as primary which is a secondary key on cq_synattr i need it to count the amount of people with the same number and make it appear on a page can anyone help me please Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/ Share on other sites More sharing options...
RussellReal Posted December 30, 2008 Share Posted December 30, 2008 r u looking for mysql_num_rows()? Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-726084 Share on other sites More sharing options...
porko2004 Posted December 30, 2008 Author Share Posted December 30, 2008 r u looking for mysql_num_rows()? yes i need it to look in db and count the name numbers together Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-726085 Share on other sites More sharing options...
RussellReal Posted December 30, 2008 Share Posted December 30, 2008 does that answer your question? lol Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-726088 Share on other sites More sharing options...
porko2004 Posted December 30, 2008 Author Share Posted December 30, 2008 no it doesnt Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-726094 Share on other sites More sharing options...
RussellReal Posted December 30, 2008 Share Posted December 30, 2008 what field in your database is their "number"? Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-726104 Share on other sites More sharing options...
porko2004 Posted January 1, 2009 Author Share Posted January 1, 2009 what field in your database is their "number"? its in cq_synattr and happy new year Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-727430 Share on other sites More sharing options...
RussellReal Posted January 4, 2009 Share Posted January 4, 2009 ok.. well try this SELECT `count`, count(`number`) FROM `cq_synattr` GROUP BY `number` Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-729335 Share on other sites More sharing options...
porko2004 Posted January 7, 2009 Author Share Posted January 7, 2009 no luck ask me if u need the sql tables ill send them Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731490 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 send the table please Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731496 Share on other sites More sharing options...
porko2004 Posted January 7, 2009 Author Share Posted January 7, 2009 wait nvm about table ive fixed it to cound how do i make it put from highers to lowest after it counts heres new script $sql = "SELECT g.name as GuildName , g.id as GuildID , COUNT(s.syn_id) as MembersCount FROM cq_syndicate as g LEFT JOIN cq_synattr as s ON (g.id = s.syn_id) GROUP BY s.syn_id DESC LIMIT 0,15 "; Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731498 Share on other sites More sharing options...
porko2004 Posted January 7, 2009 Author Share Posted January 7, 2009 this is what i mean http://58.173.92.23/test/index/shadows/guild1.htm Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731501 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 okay, click the little 'solved' option at the bottom Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731502 Share on other sites More sharing options...
RussellReal Posted January 7, 2009 Share Posted January 7, 2009 now you want to have them in order? do ORDER BY MemberCount Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-731503 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 im making somehting does anyone know how to add these to files together. please <td><div align="center">'.$row['money'].' + '.$row['money_saved'].'</td> it appears like this 686134641 + 1000 thank you Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734404 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 If you want to add numbers, don't print the + sign, but use it <td><div align="center">'.$row['money'] + $row['money_saved'].'</td> Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734406 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 doesnt work Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734416 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 Please paste larger part of code then. Would be nice if you could enclose it into [ code] tags so it look like this <td><div align="center">'.$row['money'] + $row['money_saved'].'</td> Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734420 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 please help me Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734422 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 Please paste larger part of code then. Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734427 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 <?php require('config.php'); $rank = mysql_query("SELECT name, money, money_saved FROM cq_user ORDER BY money + money_saved DESC LIMIT 0,15 ;"); $i=1; echo "<table border='3'>"; echo "<font size='9'><tr> <th><FONT COLOR=red><center> Rank </center></font></th> <th><FONT COLOR=red><center> Character Name </center></font></th> <th><FONT COLOR=red> Money </font></th> </tr></font>"; while($row = mysql_fetch_array($rank)){ echo '<td>'.$i.'-</td> <td><div align="center">'.$row['CharName'].'</td> <td><div align="center">'.$row['money'] + $row['money_saved'].'</td> </tr> '; $i=$i+1; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734432 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 Provided that both variables are set and not empty it should work. What does it display? Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734435 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 Provided that both variables are set and not empty it should work. What does it display? Can u show me what u mean Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734441 Share on other sites More sharing options...
Mchl Posted January 11, 2009 Share Posted January 11, 2009 What does the script you posted display when you run it? Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734445 Share on other sites More sharing options...
porko2004 Posted January 11, 2009 Author Share Posted January 11, 2009 its a rank page. ment to say what there rank is plus there name and money Quote Link to comment https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/#findComment-734450 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.