Hamish Posted April 18, 2007 Share Posted April 18, 2007 Hi All, I have a table presenting the returns from a MySQL query, the table is itself aligned "centre". I would like to align the cell contents "left aligned". echo("<center><table border = \"1\">"); echo("<tr><td><b>Col1</b></td><td><b>Col2</b></td><td><b>Col3</b></td><td><b>Col4</b></td>"); // loop round each record while ($rec = mysql_fetch_array($result)) { echo("<tr><td>" . $rec["Col1"] . "</td>"); echo("<td>" . $rec["Col2"] . "</td>"); echo("<td>" . $rec["Title"]. " " . $rec ["FirstName"] . " " .$rec["SName"]. " " ."</td>"); echo("<td>" . $rec["Col4"] . "</td>"); } echo("</table></center>"); Any help would be much appreciated. Regards Hamish Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/ Share on other sites More sharing options...
cyrilsnodgrass Posted April 18, 2007 Share Posted April 18, 2007 Hi Hamish, Should you not use <td align=''left"> ???? Cheers, CyrilSnod Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-231981 Share on other sites More sharing options...
clown[NOR] Posted April 18, 2007 Share Posted April 18, 2007 and from what I also can see... you havent closed the <tr></tr> tag at the end there Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-231987 Share on other sites More sharing options...
Hamish Posted April 18, 2007 Author Share Posted April 18, 2007 Thanks for all the help again. The closing tag was copy and paste error. Regards Hamish Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-232009 Share on other sites More sharing options...
Hamish Posted April 18, 2007 Author Share Posted April 18, 2007 Hi All The <td align=left> formats the data correctly, However on Transitional validation W3C gives the following error: An attribute value specification must be an attribute value literal unless SHORTTAG YES is specified. Could anyone enlighten me please? Hammish Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-232018 Share on other sites More sharing options...
AndyB Posted April 18, 2007 Share Posted April 18, 2007 echo "<td align='left'>" .... always use quotes with attributes. Just watch out for mismatched ' and " sets Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-232028 Share on other sites More sharing options...
Hamish Posted April 18, 2007 Author Share Posted April 18, 2007 Thanks AndyB, Now no errors on validation. Cheers Hammish Link to comment https://forums.phpfreaks.com/topic/47520-aligning-text-within-a-table/#findComment-232032 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.