Help - Search - Members - Calendar
Full Version: Echo Mysql Table Columns Not Aligning
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
cogs
Hello,
I'm trying to populate a table with mysql data. It populates, but the <th> and <tr> are not lining up:
Here's the output:

Application Login Password
none none none
you fix this
test test test
new new NEW
none none none

As you can see, the header (Application Login Password) isn't lining up with the rest of the rows.
Here is the code I'm using:

if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo"<table>
<th>
<td>Application</td>
<td>Login</td>
<td>Password</td>
</th>";
while($row = mysql_fetch_row($result)) {
echo "<tr>
<td>".$row[0]."</td>
<td>".$row[1]."</td>
<td>".$row[2]."</td>
</tr>";
}
echo "</table>";
Can anybody tell where I'm going wrong here?
I appreciate any help you could give.
ED
swordz
This is unusual... Can we please have the url where this is happening so we can see the error ourselves?

Thanks,
Swordz
NDBoost
just quick question... i noticed you are using <th> </th> but have nothing for the next set.. why is this?
swordz
Ah, that's it.

th is a replacement for td, not tr. The structure should be <tr><th></th></tr> ect.

Swordz
cogs
QUOTE(swordz @ Sep 30 2009, 09:51 PM) *
Ah, that's it.

th is a replacement for td, not tr. The structure should be <tr><th></th></tr> ect.

Swordz


Yeah, I finally figured that out yesterday after I tried everything else. I thought <th> replaced <tr>. Now I know! smile.gif
Thanks a lot for your help. I appreciate it!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.