Jump to content

Tables


phrozenflame

Recommended Posts

Im tring to create the second of two pages. The first page has a table that displays a row number, a count, and an error code. I want the next page to create a table by clicking on the the error code or row number. The table is suppost to diaplay the error code and all case numbers for that code. Here is an array with dummy data. In this array the counts are 3,6,10,12, the error codes are 4,5,6,7, and the case numbers are 31,41,51 for the top row, 32,42,52 for the second row and ect. The code below creates the table on the first page. Please help me create the second page. Thanks

$errcount=array(array(3,array(array(31,4),array(41,4),array(51,4))),
                array(6,array(array(32,5),array(42,5),array(52,5))),
  array(10,array(array(33,6),array(43,6),array(53,6))),
                array(13,array(array(34,7),array(44,7),array(54,7))))

<!Set up table headings>     
<html>
<table border="0" cellpadding="3">
<tr bgcolor=#CCCCCC>
<th>

</th>
<th>
# Of Events
</th>
<th>
Error Code
</th>
</tr>

<!setup table>
<? $i=0;?>
<? foreach($errcount as $C){ ?>
        <tr bgcolor= <?if($i%2 == 0) {
  echo "#EEEEEE";
      }
  else {
      echo "#CCCCCC";
      }?>>
        <td>
        <?echo $i++; ?>
        </td>
        <td>
        <? echo $C[0]; ?>
        </td>
        <td>
        <? echo $C[1][0][1]; ?>
        </td>
        </tr>
<? } ?>
</table>
</html>
Link to comment
https://forums.phpfreaks.com/topic/32384-tables/
Share on other sites

What do you mean by "second page"?

BTW, you code can be cleaned up a little:
[code]
<table border="0" cellpadding="3">
<tr bgcolor=#CCCCCC>
<th>

</th>
<th>
# Of Events
</th>
<th>
Error Code
</th>
</tr>

<!setup table>
<?php $i=0;
for ($i=0;$i<count($errcount);$i++) {
        $C = $errcount[$i];
$bg = ($i%2 == 0)?'#EEEEEE':'#CCCCCC'; ?>
        <tr style="background-color:<?php echo $bg ?>">
        <td>
        <?php echo $i; ?>
        </td>
        <td>
        <?php echo $C[0]; ?>
        </td>
        <td>
        <?php echo $C[1][0][1]; ?>
        </td>
        </tr>
<? } ?>
</table>[/code]

Ken
Link to comment
https://forums.phpfreaks.com/topic/32384-tables/#findComment-150393
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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