Jump to content

snup

New Members
  • Posts

    4
  • Joined

  • Last visited

Posts posted by snup

  1.  

    And that is what my code does. Example output from my code

    <div class="tr normal ftr rd1">...</div>
    <div class="tr normal ftr rd2">...</div>
    <div class="tr normal ftr rd3">...</div>
    <div class="tr normal">...</div>
    <div class="tr normal odd">...</div>
    <div class="tr normal">...</div>
    <div class="tr normal odd">...</div>
    ...etc

    Sorry I was reading it all on my phone and was a bit confused. But got it fixed now! You're the man thanks so much!

  2. Wait... Before you said the top three rows will be rd1 for first row, rd2 for second row and rd3 for the third. Now you are saying the top three rows alternate between rd1 and rd2? Which is it?

    my bad i didn't notice i wrote that already

     

    rd1 is bold yellow

    rd2 is bold lighter yellow

    rd3 is bold yellow - the same as rd1

  3.  

    So the first three rows will have the the rdX class applied. Then the remaining rows have the odd class is applied alternatively?

     

    Using your $counter variable we can alternate the classes at the start of the loop, example (untested code)

    $counter = 1;
    while ($fetch = mysql_fetch_assoc($result)) {
    
       // common css classes for every row
       $class = "tr normal";
    
       // if counter is less than or equal to 3 apply the ftr and rdX css class
       if($counter <= 3) {
           $class .= " ftr rd$counter";
       }
       // otherwise apply the odd css class for every alternative row
       else if($counter % 2 != 0) {
           $class .= " odd";
       }
      
       // apply the css class definitions
       echo '<div class="'.$class.'">
       ....
       </div>';
       $counter++;
    }

    First thanks for the reply and help

     

    The first three I am trying to have: 

    1) <div class="tr normal ftr rd1">

    2) <div class="tr normal ftr rd2">

    3)<div class="tr normal ftr rd1">

     

    The first three are in bold to show top 3 players but are slightly different in color tone so show difference then the rest after that are even and odd to show different colors like you have posted

  4. Okay, so I am trying to display players usernames and kills and deaths from my highscores page and I have different div classes set for each block This is my code:

    <div id="table">
    <div class="tr ttl">
    <div class="col st1">Rank</div>
    <div class="col st2">Username</div>
    <div class="col st3">Rating</div>
    <div class="col st4">Deaths</div>
    <div class="col st5">Kills</div>
    </div>
    <?php
    if($_GET['skill'] == 0) {
    $skill = $_GET['skill'];
    $page = ($_GET['page']-1);
    $limit = RESULTS_PER_PAGE*$page.', '.RESULTS_PER_PAGE;
    $limitt = RESULTS_PER_PAGE*$page;
    $query = "SELECT * FROM hs ORDER BY `elo` DESC LIMIT ".$limit."";
    $result = mysql_query($query);
    $counter = 1;
    while ($fetch = mysql_fetch_assoc($result)) {
    echo '<div class="tr normal ftr rd1">
    <div class="col st1">'.($counter+$limitt).'</div>
    <div class="col st2"><a href="?user='.$fetch['username'].'">'.$fetch['username'].'</a></div>
    <div class="col st3">'.number_format($fetch['kills']).'</div>
    <div class="col st4">'.number_format($fetch['deaths']).'</div>
    <div class="col st5">'.$fetch['elo'].'</div>
    </div>
    ';
    $counter++;
    }
    }
    ?>

    See where it says echo '<div class="tr normal ftr rd1"> 

     

    I'd want it to print out like this:

     (tr normal ftr rd1) for the first one, (tr normal ftr rd2) for second one and (tr normal ftr rd3) for the 3rd one.

    Then (tr normal) and (tr odd normal) for the rest

    Can anyone help me out here?

     

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