tags:

views:

73

answers:

4

I'm creating an overview with data from a database. But in Chrome (and Safari and Opera) The <td></td> content starts on a new line, while Firefox and IE(8) display it on the same line.

Name Event: <td>'.mysql_real_escape_string(mysql_result($result, $i,"event_title")).'</td>
Max # Persons: <td>'.mysql_real_escape_string(mysql_result($result, $i,"max_participants")).'</td>
Total Guests: <td>'.mysql_real_escape_string($row['total_guests']).'</td>    
Status Event: <td>'.$status.'</td>

Example:
Chrome:
Name Event:
Wedding


FireFox:
Name Event: Wedding

The same happens when I end every line with a <br> or <br/>

Is there a (easy) workaround to fix this?

+8  A: 

This is invalid HTML. How it will be rendered is totally undefined.

Inside a table, any text content must be inside <td> (or <th>) tags.

You need to put the labels into <td> tags as well, and wrap everything in <tr>s.

A complete mini-structure for a table would look like this:

<table>
 <tr>
  <td>Name Event: </td><td>...</td>
  <td>Max # Persons:</td><td>...</td>
  <td>Total Guests:</td><td>...</td>
  <td>Status Event:</td><td>...</td>
 </tr>
</table>
Pekka
I suggest that you use <th>...</th> around the header fields.
some
@some: Pretty sure Pekka was just trying to keep things as simple as possible so the OP could understand the basic tag hierarchy.
webbiedave
You guys ROCK! I managed to fix this by using a simple <ul>.
Chris Bogaards
A: 

Are your td tags contained within tr tags, contained within a table tag? If not properly included in such a hierarchy, the appearance of td tags might be undefined.

Andrew Barber
This is the complete code from the 'functions.php' file: [img] http://grab.by/6EBKAnd this is the index.php: <div id="EventInfo"> Evenement Informatie:<br/><br/> <?php echo getMyUserEvents($id); ?></div>
Chris Bogaards
The TR tag being created above is being closed before the TD tags come. You need to move the closing TR tag below. Also, you need to move the headings into the TD tags, or create TD/TH tags for them, also within the TR tags.
Andrew Barber
+1  A: 

Table structure should be like so:

<table>
  <tr>
    <td>Name Event: </td><td>'.mysql_real_escape_string(mysql_result($result, $i,"event_title")).'</td>
    <td>Max # Persons: </td><td>'.mysql_real_escape_string(mysql_result($result, $i,"max_participants")).'</td>
    <td>Total Guests: </td><td>'.mysql_real_escape_string($row['total_guests']).'</td>    
    <td>Status Event: </td><td>'.$status.'</td>
  </tr>
</table>
Martin
This is the complete code from the 'functions.php' file: [img] http://grab.by/6EBK I don't think I'm able to do it like that...?
Chris Bogaards
@Chris yes, but it should be easy enough to adjust. You simply need to wrap everything in `<td>`s
Pekka
Just wrap "Naam Event:" as "<td>Naam Event:</td>" - note you also have an error at the end of your code, your br tag is missing a closing brace - <br/. In fact remove your br tags, they don't need to be there. Follow this tutorial, it looks like you need to get to the basics - http://www.w3schools.com/html/html_tables.asp
Martin
+1  A: 

The reason it looks different in different browsers is that your HTML is invalid, so there's no guaranteed result - each browser will try to do their best to work out what you mean, but you can't be sure they'll come to the same conclusion.

<td> is supposed to be part of an HTML table. You should either restructure it so that everything is in correctly formatted <table>, <tr> and <td> tags, or switch to using a different type of tag (there are several that could be suitable).

Either way, if you structure it correctly, it will render the same in different browsers.

Spudley