Jump to content


Photo

PHP generated color table will not show in IE 6


  • Please log in to reply
2 replies to this topic

#1 Squall2131

Squall2131
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 26 February 2006 - 04:42 AM

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*

<!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>


#2 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 26 February 2006 - 05:09 AM

These lines give a hint:
<?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>");
?>
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:
<?php
                    print("<td align='center' bgcolor='#" .$r .$g .$b ."'> </td>\n");
?>
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

#3 Squall2131

Squall2131
  • Members
  • Pip
  • Newbie
  • 4 posts

Posted 26 February 2006 - 05:18 AM

Thanks a lot, i didn't even notice the "nbsp;" when i was editing the file.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users