Jump to content

[SOLVED] Php question please help


porko2004

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/138851-solved-php-question-please-help/
Share on other sites

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

              ";

<?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;

}

 

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.