Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
Necuima

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

 

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites

It's a common misconception that it's invalid to use single quotes around attributes in HTML. It's actually allowed (single or double). 

Share this post


Link to post
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:-)

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...