[Help] Php page showing wrong order of ranks

FirefighterKyle

I am Kyle!!
Sep 14, 2012
162
7
Okay so I am trying to make a rank page for a game I am playing, I am having a hard time understanding why it shows the wrong ranks when I am calling something else.

Here is my code.
PHP:
<?php
   
        $rankCount = mysql_num_rows(mysql_query("SELECT * FROM `ranks` WHERE `type` = '1' && `branch` = 1"));
       
        if ($rankCount > 0)
        {
            for ($i=1; $i<=$rankCount; $i++)
            {
                $rankInfo = mysql_fetch_array(mysql_query("SELECT * FROM `ranks` WHERE `ladder` = '".$i."'"));
                $getMembers = mysql_query("SELECT * FROM `members` WHERE `position` = '".$rankInfo['id']."' ORDER BY `update_date` ASC");
               
                echo '<a href="#">'.$rankInfo['title'].' ('.mysql_num_rows($getMembers).')</a><br />';
               
                if (mysql_num_rows($getMembers) > 0)
                {
                    while($memberInfo = mysql_fetch_array($getMembers))
                    {
                        
                    echo '<table width="100%">
                            <tr>
                                <td>
                                    <strong>Name:</strong> <a href="/member/'.$memberInfo['id'].'">'.$memberInfo['name'].'</a><br />
                                    <strong>Tag:</strong> '.$memberInfo['tag'].'<br />
                                    '.$memberInfo['train_promo'].' <strong>'.$memberInfo['promo_by'].'</strong> on '.date("m/d/y", $memberInfo['update_date']).'<br />
                                    <strong>Graded by:</strong> '.$memberInfo['graded_by'].'<br /><br />
                                </td></tr></table>';
                       
                    }
                }
                else
                     '<i>There currently no on in this position.</i><br />';
            }
        }
        else
             '<i>This branch has no ranks yet please check back later.</i>';
    ?>

R7CG60h.png

It should show (Private, PFC, Senior Private, and Corporal) but it is showing the last 4 like so (Minister of HS, Director oO, General, and Lieuten Gen) Why won't it show the Private etc since I am saying to show "`type` = 1" ??
 

Proximity

IDK?
Feb 13, 2014
673
56
I think it should be like

$rankInfo = mysql_fetch_array(mysql_query("SELECT * FROM `ranks` WHERE `ladder` = '".$i." AND ORDER ASC'"));

I think its something like that I am still learning so
 

Weasel

👄 I'd intercept me
Nov 25, 2011
4,135
2,461
Try this:
PHP:
<?php
$resultRanks = mysql_query("  
    SELECT      `ranks`.`title`,
                `ranks`.`id`
    FROM        `ranks`
    ORDER BY    `ranks`.`ladder` ASC
");
$countRanks = mysql_num_rows($resultMembers);

if ($countRanks > 0)
{
    while ($rowRanks = mysql_fetch_assoc($resultRanks))
    {
        $resultMembers = mysql_query(" 
            SELECT      `members`.`id`,
                        `members`.`name`,
                        `members`.`tag`,
                        `members`.`train_promo`,
                        `members`.`promo_by`,
                        `members`.`update_date`,
                        `members`.`graded_by`
            FROM        `members`
            WHERE       `members`.`position` = '" . $rowRanks["id"] . "'
        ");
        $countMembers = mysql_num_rows($resultMembers);

        echo '<a href="#">' . $rankInfo['title'] . ' (' . $countMembers . ')</a><br />';

        if ($countMembers > 0)
        {
            while ($rowMembers = mysql_fetch_assoc($resultMembers))
            {
                echo '<table width="100%">
                        <tr>
                            <td>
                                <strong>Name:</strong> <a href="/member/' . $rowMembers['id'] . '">' . $rowMembers['name'] . '</a><br />
                                <strong>Tag:</strong> ' . $rowMembers['tag'] . '<br />
                                ' . $rowMembers['train_promo'] . ' <strong>' . $rowMembers['promo_by'] . '</strong> on ' . date("m/d/y", $rowMembers['update_date']) . '<br />
                                <strong>Graded by:</strong> ' . $rowMembers['graded_by'] . '<br /><br />
                            </td>
                        </tr>
                      </table>';
            }
        }
        else
        {
            echo '<i>There currently no on in this position.</i><br />';
        }
    }
}
else
{
    echo '<i>This branch has no ranks yet please check back later.</i>';
}
?>
 

Users who are viewing this thread

Top