Problem with alignment in table

Need help with a table in php.  I'm trying to do a table that has a header on the top ("Other remarks"). This is going to followed by the data.  The columns are all being justfied to the right and the header is not centered.  I've attached the code. I can see why this doesn't work.
wtf.php
breeze351Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gr8gonzoConsultantCommented:
First, you have several HTML validity issues.
If you want to use HTML 5, just use "<!DOCTYPE html>" as your doctype:
<!DOCTYPE html>
<html>

Open in new window


Next, you've put all your content OUTSIDE your <body> block, which can cause some weird behavior for sure. It should look more like this:
<body>
<?php
$work = "in1";
echo '<table width = "100%" align = "left" id="Table3" style="border: 1px  solid black">';
echo "<tr>";
	 echo '<td width = 100% class = "Space_Display" align="center"> Other Remarks<td></tr>';
	 echo "<tr>";
	 	echo '<td width = 10% class = "Space_Display" align="left"> In-House<td>';
			echo '<td width = 30% align = "left">';
				if ($Display == "D")
				{
					echo $work;
				}
				else
				{
					echo '<input type="text" class = "k1" name="In_Remark1" size = "60" value="';
					echo $work;
					echo '" maxlenghth="60" title="In-House Remarks Line 1">';
 				}
			echo "</td>";

echo '<td width = 10%>';
echo "gd";
echo '</td>';



echo '<td width = 15% class = "Space_Display" align="left"> Private<td>';
echo '<td width = 30%>';
echo 'Fred Private</td>';
echo "</tr>";
?>
</table>
</body>
</html>

Open in new window


Next, you should add quotes around your width values, like this:
<td width="50%">


Next, you have several instances where your closing </td> tag is actually "<td>" instead of "</td>"
echo '<td width = 100% class = "Space_Display" align="center"> Other Remarks<td></tr>';

echo '<td width = 10% class = "Space_Display" align="left"> In-House<td>';

echo '<td width = 15% class = "Space_Display" align="left"> Private<td>';

Next, you should really try to stay consistent with your line breaks when you're building your table rows and cells. Don't do this:
<tr>
  <td>content A</td></tr>
<tr><td>content B</td></tr>
<tr>
  <td>content C</td>
</tr>

Pick one format and stick with it to make your code easier to read in the future. If you have multiple columns (which is usually the case), I recommend putting <tr> and </tr> on their own lines, and then each <td></td> on its own line, like this:

<tr>
  <td>content</td>
  <td>content</td>
  <td>content</td>
</tr>

Next, you have a misspelling in "maxlength", which will probably cause confusion if you don't correct it.

Finally, your first row has only one column, and your next row has 5 columns. You should use colspan on the first row's <td> to indicate how many columns that should take up. For example:

echo "<tr>";
       echo '<td width = 100% class = "Space_Display" align="center" colspan="5"> Other Remarks</td></tr>';
2

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
breeze351Author Commented:
Thanks.  Got it.
0
breeze351Author Commented:
Got it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.