I recently tried to use a script of Spoono's for the alternating table row colors... unfortunately, i could not get it to work, but this is the closest i've gotten. The result is a page that takes forever (not exaggerating) to load, and once you press the stop button, it displays the table headers, but never the php and the actual page itself is very very long (as in the scrollbar gets small)

here's the code, hopefully it's somethign stupid and i dont have to change much

<html>
<head>
<LINK REL="StyleSheet" HREF="style.css" TYPE="text/css">
<script language="JavaScript">
<!--

function openwindow(url)
{
newwindow=window.open(url, 'name', 'toolbar=mp,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no,copyhistory=yes,width=400,height=350');
        if (window.focus) {newwindow.focus()}
}

//-->
</script>
</head>
<body bgcolor="#515151" style="margin:0;scrollbar-face-color: #515151; scrollbar-shadow-color: #666666; scrollbar-highlight-color: #515151; scrollbar-3dlight-color: #666666; scrollbar-darkshadow-color: #515151; scrollbar-track-color: #515151; scrollbar-arrow-color: #888888;">

<table width="100%" cellpadding="0" cellspacing="0" border="0">

<tr><td width=50><span class="table_header">Ladder</td><td width=80><p class="table_header">Date</td><td width=80><p class="table_header">Clan</td><td width=50><p class="table_header">LORD</td><td width=50><p class="table_header">Them</td><td width=60><p class="table_header">Outcome</td><td><p class="table_header">Screenshots</td></tr>
  <?
include("config.php");
include("functions.php");
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
mysql_select_db($db) or die ("Unable to select database!");

  $query = "SELECT battle_id, battle_ladder, battle_date, battle_clan, battle_lordscore, battle_themscore, battle_outcome, battle_map1_url, battle_map1, battle_map2_url, battle_map2, battle_map3_url, battle_map3, timestamp FROM battles ORDER BY timestamp DESC";
  $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());

if ($row = mysql_fetch_array($result)) {
    //run the for loop
    for ($i = 0; i < count($row); $i++) {
     // Set Table Row Color
         if ($i % 2) {
             echo "<tr bgcolor=4a4a4a>";
         } else {
             echo "<tr bgcolor=4d4d4d>";
         }
        // Now display our table cell info
    }

?>
<td><p><? echo $row["battle_ladder"]; ?></td><td><? echo $row["battle_date"]; ?></td><td><? echo $row["battle_clan"]; ?></td><td><? echo $row["battle_lordscore"]; ?></td><td><? echo $row["battle_themscore"]; ?></td><td><? echo $row["battle_outcome"] ?></td><td><a href="<? echo $row["battle_map1_url"]; ?>"<? $row["battle_map1"]; ?></a>&nbsp;&nbsp;&nbsp;<a href="<? echo $row["battle_map2_url"]; ?>"<? $row["battle_map2"]; ?></a>&nbsp;&nbsp;&nbsp;<a href="<? echo $row["battle_map3_url"]; ?>"<? $row["battle_map3"]; ?></a></td>
<? }
?>
mysql_close($connection);
</tr>

</table>


</body>
</html>

any help would be appreciated -- thanks

    i i just notcied / fixed the url problem i had in there -- still doesnt work

      Looks like an infinite loop, probably because of this line:

      for ($i = 0; i < count($row); $i++) {
      should be:
      for ($i = 0; $i < count($row); $i++) {

      and I'd suggest to move the mysql_close()-command inside <?php ?> tags.

      Hope this gets you closer,
      xblue

        Anyway, this still isn't likely to produce the desired output.
        As far as I can tell, you are trying to decide which color the
        row should have by checking the number of columns which
        doesn't make much sense to me. I tried to rearrange things
        a little:

        
        <?php
        include("config.php");
        include("functions.php");
        $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
        mysql_select_db($db) or die ("Unable to select database!");
        
        $query = "SELECT battle_id, battle_ladder, battle_date, battle_clan, battle_lordscore, battle_themscore, battle_outcome, battle_map1_url, battle_map1, battle_map2_url, battle_map2, battle_map3_url, battle_map3, timestamp FROM battles ORDER BY timestamp DESC";
        $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
        
        while ($row = mysql_fetch_array($result)) {
            $i++;
            if ($i % 2) {
                echo "<tr bgcolor=4a4a4a>";
            } else {
                echo "<tr bgcolor=4d4d4d>";
            }
            echo "<td><p>$row['battle_ladder']</td><td>$row['battle_date']</td><td>echo $row['battle_clan']</td>(and so on)";   
        echo "</tr>";
        } mysql_close($connection); ?> </table>
          include("config.php"); 
          include("functions.php"); 
          $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); 
          mysql_select_db($db) or die ("Unable to select database!"); 
          
          $query = "SELECT battle_id, battle_ladder, battle_date, battle_clan, battle_lordscore, battle_themscore, battle_outcome, battle_map1_url, battle_map1, battle_map2_url, battle_map2, battle_map3_url, battle_map3, timestamp FROM battles ORDER BY timestamp DESC"; 
          $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); 
          
          while ($row = mysql_fetch_array($result)) { 
          $i++; 
          if ($i % 2) { 
          echo "<tr bgcolor=4a4a4a>"; 
          } else { 
          echo "<tr bgcolor=4d4d4d>"; 
          } 
          echo "<td><p>$row['battle_ladder']</td><td><p>$row['battle_date']</td><td><p>$row['battle_clan']</td><td><p>$row['battle_lordscore']</td><td><p>$row['battle_themscore']</td><td><p>$row['battle_outcome']</td><td><p><a href=\"$row['battle_map1_url']\">$row['battle_map1']</a>   <a href=\"$row['battle_map2_url']\">$row['battle_map2']</a>   <a href=\"$row['battle_map3_url']\">$row['battle_map3']</a></td>"; 
          echo "</tr>"; 
          } 
          mysql_close($connection); 
          ?> 
          </table>

          gives the response:

          Parse error: parse error, expecting T_STRING' orT_VARIABLE' or `T_NUM_STRING' in /home/teamlord/public_html/v1/index_battles.php on line 37

          i'm goint to keep trying to find the problem, but once again, help would be appreciated

            Try this:

            <?php
            // For alternate row colour
            $row_colour="#FFFFCC";
            $count_rows = 0;

            //loop and display the limited records being browsed
            while ($arr = mysql_fetch_array($rs))
            {
            $count_rows++;
            if ($count_rows%2==0)
            { $row_colour="#FFFFCC"; } // Even-numbered rows
            else
            { $row_colour="#CCCC99"; } // Odd-numbered rows
            ?>

            <tr bgcolor="<?php echo $row_colour; ?>"> <!-- Alternate Row Colours -->
            <td></td></tr>
            <?php }; ?>
            </table>

            Tell me if it doesnt work! 😉

              it works man, thanks a lot!!!

              now that I think abotu it, that makes moe sense than the first one... anyway, thanks!

                Write a Reply...