Pavlin24 Posted April 13, 2014 Share Posted April 13, 2014 Hallo, can anybody help me about this questuon. Is it possible to style HTML table heading, when it is in PHP? I mean something like this: <?php echo "<table border='1'> <tr> <th style='width:150px;'>дата на док.</th> </tr> </table> " ?> This not work . I want to set width of the heading to be 150 px. Is there other way? Link to comment Share on other sites More sharing options...
Petrucho Posted April 13, 2014 Share Posted April 13, 2014 This code should work. What you see in your browser while trying to load the page? it show's you anything? Link to comment Share on other sites More sharing options...
dsonesuk Posted April 13, 2014 Share Posted April 13, 2014 (edited) Add semicolon (;) to end of echo code. It is better to use single quotes to contain text, also use a class to style the table header <style type="text/css"> table, td, th {border: 1px solid #000;} /*style all tables, td , th */ .table01 th {width: 150px} /*only style table with class table01 th */ </style> <?php echo '<table class="table01"> <tr> <th>дата на док.</th> </tr> </table>'; ?> Then if changes required you just edit stylesheet. Edited April 13, 2014 by dsonesuk Link to comment Share on other sites More sharing options...
Pavlin24 Posted April 14, 2014 Author Share Posted April 14, 2014 To Petrucho: No errors are shown. Everything works, except of styling the width of this column. To dsonesuk: I have semicolon. I replaced the double quotes, I tried with class too, no result. But I found that the same code placed in other file works! I even copied the code from working file to not-working, but it still do not work in second file. It is some kind of mystery. Link to comment Share on other sites More sharing options...
dsonesuk Posted April 14, 2014 Share Posted April 14, 2014 I've only seen this happen when in notepad the file is saved as encoded: ansi, when it should be saved as encoded: utf-8 Link to comment Share on other sites More sharing options...
davej Posted April 16, 2014 Share Posted April 16, 2014 Why does this code need to be echoed? Why not just put it outside the Php block? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now