Problem solving

O.k. so I just wasn’t happy with the php script I was using to list my eBay items on this site so I went and found another one. What’s there now is not as elegant as the original one but it works better. Trouble is, when I put the script into the page, the table it was generating was way off. The header row was correct but the data rows were all shifted one cell to the right. Ah, the joys of having one to many cells in just one row of your table. The bigger problem was that the table was being generated by the php script and I know absolutely nothing about php. So, off I go poking through the script trying to find the problem. No real luck there. So, off to the resulting HTML page. I poke around in the source code of the resulting page and find a wonderful bit of code:

<TD bgcolor="#fff"><td color="">

Ah ha, there’s the extra cell being generated. But, when I look at the relevant area of the script I can’t seem to find anything that would be generating <td color=""> anywhere. Then I spot a section of the script labeled “Get rid of some rubbish we don’t need.” That sounded promising. Looking through it further I determined that it’s getting way to much from the eBay data file and that section dumps the extraneous code. Copying the other lines in that section I created the following new line:

$content[1] = str_replace("<td color=\"\">", "", $content[1]);

I saved the change and, miracles of miracles, it solved the problem!

What’s the point of sharing this story? (Especially since I know some of you didn’t understand a word of it…) Well, mainly to point out why I believe that when you teach computers you shouldn’t just teach what the student needs to know to accomplish a task. You also need to include the explanations of hows and whys that explain how and why what their doing does what it does. For example, in this case, I didn’t know squat about php going into the problem but because I knew some underlying theory about how scripting languages work (along with how HTML tables work) I was able to piece together a solution. That’s why I “bother” to take the time to explain things in my workshops and books.

Posted in 1Tagged

Leave a Reply

Your email address will not be published. Required fields are marked *