Jump to content
Larry Ullman's Book Forums

Problem With Html Table Generated With Php Echos


Recommended Posts

Hi Larry,

 

I'd like to ask help with a problem that I am experiencing with an HTML table which is generated by PHP echos.

 

When it renders in a browser, four spurious sem-colons appear at the top of the table - in Firefox they are aligned horizontally; in IE9 they are aligned vertically, both on the left hand side of the area immediately above the table itself. Maybe relatedly the table has four columns.  It does not need or have a header but I have tried adding blank <th></th> pairs but it makes no difference.

 

The table itself renders perfectly.

 

 

echo '<table>';
.... other MySQL code here ...
echo "<tr>
               <td rowspan='2'>
                <div align='center' class='index_table_icon'>
                 <a href='./link to the page that this icon refers to'>
                 <img src='$icon1' alt=''>
                 </a>
                </div>
               </td>
               <td valign='bottom'>
                 <a class='text_link' href='./link to the page that this icon refers to'>
                 $cats[2]
                 </a>
               </td>
               <td rowspan='2'>
                <div align='center' class='index_table_icon'>
                 <a href='./link to the page that this icon refers to'>
                 <img src='$icon2' alt=''>
                 </a>
                </div>
               </td>
               <td valign='bottom'>
                 <a class='text_link' href='./link to the page that this icon refers to'>
                 $cats[4]
                 </a>
               </td>
              </tr>;
              <tr>
               <td>
                <p class='index_maintext'>
                $cats[5]
                </p>
               </td>
               <td>
                <p class='index_maintext'>
                $cats[6]
                </p>
               </td>
              </tr>
              <tr>
               <td> </td>
              </tr>";
echo "</table>";

 

My environment is a Win 7 64 bit PC, Firefox, IE9, Apache, PHP, MySQL.  All executions are via localhost.

 

Many thanks in anticipation for any assistance that can be provided.

 

Best regards, Necuima

 

Link to comment
Share on other sites

Try taking the semicolon out of the following line midway through your code:

 

</tr>;

 

Also, it's not valid HTML to use single quotes for attribute values.

You should use only double quotes for HTML attribute values (which is why I generally use single quotes to mark strings that I'm echoing in PHP that contain HTML).

Link to comment
Share on other sites

Hi HartleySan, Larry,

 

So obvious!!!  You know that I looked at that code till I was blue in the face, to use a local colloquialism, and didn't see that spurious semi-colon!!

 

Many many thanks!!

 

Cheers from Oz:-)

Link to comment
Share on other sites

We use the expression "blue in the face" in America too.

I had the exact same conversation with my Australian co-workers the other day, who all thought that that expression was exclusive to Australia.

 

Anyway, glad you solved your problem, and sorry about the misinformation with the single/double quotes.

Link to comment
Share on other sites

 Share

×
×
  • Create New...