Jump to content

A little help


Insecure

Recommended Posts

I am looking for a little help with some php.  The code that I have posted is all working properly, but as you can tell it is pretty messy and I think is probably the hardest way to come up with the results.  I am wondering if anyone can help me clean up this code a little.  I am not a pro by any means with php but I do understand a bit.  I have never been able to really understand the join option in MySQL and I'm thinking that might help me here but I am not sure.  If any one has any ideas of how to make this cleaner I would appreciate the feedback.

 

  $info = '';

   $rgs_sql = $db->query("SELECT * FROM " . DB_RANKGROUPS . " WHERE `display` = '1' ORDER BY `displayorder` DESC");
    while($rgs = $db->fetch_array($rgs_sql)) {
     $rankgroupID = $rgs['id'];
     $rankgroupName = $rgs['groupname'];
      
       $info .= "
       <table width='75%'>
        <tr>
         <td><center><font size=+1 color=white><strong>$rankgroupName</strong></font></center></td>
        </tr>
       </table>
      
       <table width='75%'>
        <tr>
         <td width='15%'><strong>Rank</strong></td>
         <td width='25%'><strong>Username</strong></td>
         <td width='20%'><strong>Content</strong></td>
         <td width='20%'><strong>DSL</strong></td>
         <td width='15%'><strong>Online Status</strong></td>
        </tr>
       ";

     
      $ranks_sql = $db->query("SELECT * FROM " . DB_RANKS . " WHERE `display` = '1' AND `group` = '$rankgroupID' ORDER BY `ranknum` DESC");
      while($ranks = $db->fetch_array($ranks_sql)) {
       $rank = $ranks['ranknum'];
        
        $sql = $db->query("SELECT * FROM " . DB_MEMBERS . " WHERE `rank` = '$rank' AND `status` = '1' ORDER BY `username` ASC");
        while($row = $db->fetch_array($sql)) {
          $username = $row['username'];
          $rank     = $row['rank'];
          $dsl      = "Hello";
          $onlinestatus = "on"; //$users->getOnlineStatus($row['id']);
          
          $info .= "
           <tr>
            <td width='20%'><img src='".RANK_IMAGES."/$rank.".RANK_IMAGES_EXT."'></td>
            <td width='25%'><a href=index.php?page=Members&profile=$username>$username</a></td>
            <td width='20%'>Content</td>
            <td width='20%'>$dsl</td>
            <td width='15%'><center><img src=/includes/images/$onlinestatus.gif'></center></td>
           </tr>
          ";
         
         }
             
     }
      
     $info .= "
     </table><br>
     ";    
    }

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.