Web Analytics Made Easy -
StatCounter Need assistance with while loop to rotate bg colors - CodingForum

Announcement

Collapse
No announcement yet.

Need assistance with while loop to rotate bg colors

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Need assistance with while loop to rotate bg colors

    Below is the snippet of code. I'd like to rotate <td align=center class=reverseeven> and <td align=center class=reverseodd>. I've reached an impasse..

    PHP Code:
    <table class="reverse" rules="rows" style="width: 90%">
        <tr> 
            <td class="reversetitle">File Description</td>
            <td align="center" class="reversetitle">Downloads</td>
            <td align="center" class="reversetitle">Last Download</td>
        </tr>
        <?php 
        
    include_once ("download_cfg.php");
        
    $handle = @opendir("$dircount"); 
        if (
    $handle==FALSE){
        echo 
    "Error:no counter directory [$dircount] found";
        return;
        }   
        
    $files = array();
        
    $cnt ;
        
        while(
    false!==($file=readdir($handle))){
        if (
    $file!='.' && $file!='..' && $file!=".htaccess"){
        
    $files[$cnt] = $file;
        
    $cnt $cnt 1;
        }
        }
        
    closedir ($handle);
        
    sort($files);
        for (
    $cnt=0;$cnt<count($files);$cnt++) {
        
    $filenm   $dircount.$files[$cnt];
        
    $fd       fopen ($filenm "rb");
        
    $fcounter   explode("::",fgets($fd1024));
        
        
    fclose($fd);
        
    // display file name and the counter.
        
    echo "<tr><td class=reverseeven>$fcounter[1]</td>";
        
    $files[$cnt]=substr($files[$cnt],0,strlen($files[$cnt])-4);
        echo 
    "<td align=center class=reverseeven>$fcounter[0]</td>";
        
    $filemodtime date("F j, Y "filemtime($filenm ));
        echo 
    "<td align=center class=reverseeven>$filemodtime</td></tr>";   
    ?>
    </table>

  • #2
    In general, modulo will work for this, the concept is as follows:

    PHP Code:
    $i 0;
    while(
    something) {
        
    $i++;
        if(
    $i == 0) {
             
    $class="even";
        }
        else {
            
    $class="odd";
        }

    Create accessible online surveys -::- Koobten.com - compare netbook prices and reviews -::- Affordable, reliable hosting for less than $20 per year
    Zend Certified Engineer

    Comment

    Working...
    X