Jump to content

PHP generated color table will not show in IE 6


Squall2131

Recommended Posts

Can anyone tell me why this php generated table won't show up in internet explorer 6??
The source code was from planetsourcecode.com, and I validated the site with W3C. This code works in Opera 9 and Firefox 1.5 Beta.
It looks complicated, but all it does is produce a table with web safe colors for each cell background. In IE 6 the outline of the table shows up, but none of the cells or its colors; Just an empty table. When i view the source it has all the code in the page. *stumpted*

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<?
   print("<table align='center' border='2' cellspacing='0' cellpadding='5' width='30%'>");
    // variables r,g,b are string values for
    //     Red, Green Blue
    $r = "00";
    $g = "00";
    $b = "00";
    // variables numr, numg, numb are numeri
    //     c values
    $numr = 0;
    $numg = 0;
    $numb = 0;
    // Variables i, j, k are counters
    for ($i = 0; $i <= 5; $i++) {
        for ($j = 0; $j <= 5; $j++) {
            print("<tr>");
                for ($k = 0; $k <= 5; $k++) {
                    //print out the html which will send a querystring with te selected hex value
                    print("<td align='center' bgcolor='#" .$r .$g .$b ."'>");
                    //non-breaking spaces give clickablity.
                    print("</td>");
                    // Incrementing Blue by 51 each time produces Web safe colors
                    $numb += 51;
                    //convert the numeric $b into hex
                    $b = dechex($numb);
                } //close for $k
            //reset blue variables to 0
            $b = "00";
            $numb = 0;
            // Incrementing Green by 51 each time produces Web safe colors
            $numg += 51;
            //convert the numeric $g into hex
            $g = dechex($numg);
            print("</tr>");
        } //close for $j
    //reset green variables to 0
    $g = "00";
    $numg = 0;
    // Incrementing Red by 51 each time prod
    //     uces Web safe colors
    $numr += 51;
    //convert the numeric $r into hex
    $r = dechex($numr);
    } //close for $i
    print("</table>");
?>
</body>
</html>
[/code]
Link to comment
Share on other sites

These lines give a hint:
[code]<?php
                    //print out the html which will send a querystring with te selected hex value
                    print("<td align='center' bgcolor='#" .$r .$g .$b ."'>");
                    //non-breaking spaces give clickablity.
                    print("</td>");
?>[/code]
It looks like this used to produce a link for each background color and used the " " to make each cell clickable. When you (or whomever took away the link) changed to code, they also removed the "nbsp;". MSIE sees the empty table cell and collapses it down to nothing. All the other browsers collaspe the cells down to the minimumm size.

I changed the code to be:
[code]<?php
                    print("<td align='center' bgcolor='#" .$r .$g .$b ."'> </td>\n");
?>[/code]
I put back the " " and put the "</td>" in the same print statement. I also added a few "\n" to make the resulting code eaiser for humans to read.

The code now works correctly on both FF and MSIE.

Ken
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.