Re: Help on how to set column widths in php
I am using a php view to show a table of all the entrants in my projects with their number, name, rounds and points.
I have two projects Project One and Two which have their results displayed in tables. The width of the columns for the values in these projects are dependent on the size of the name of the person, or club or points, making the table views slightly offset. The data records are read from a mysql database tables
i.e if the name is Fred Bloggs then the name column is only 11 characters wide, whereas if the name is Frederick Wilkinson then the column is 20 characters wide.
If Fred Bloggs is in project one and Frederick Wilkinson is in Project two, then when they are viewed on the web page then the Table for Project one is not as wide as for project two, making them look offset and not professional.
I would like to be able to define the width of each field, so as an example lets say the name field to be 25 characters and be padded with blanks if the name is shorter. Yes I understand that if the name was 26 characters it would be truncated and accept that, but as my individuals are fixed, I can live with that.
The php code is displayed below, but I don't know how to amend it to fix the column widths and would really appreciate some advice. I am sorry but I am not a php coder, so would appreciate instructions to update the code if at all possible?
It would be far easier to just set a column min-width in the CCS. You can set column specific information for the table by assigning classes inside the <col> and <colgroup> tags that precede the <thead> tag.
The other thing you haven't taken into account is that with most fonts the characters are not all the same width and so iiiiiiiiiiiiiiiiiiiiiiiii is not the same width as MMMMMMMMMMMMMMMMMMMMMMMMM even though both are 25 characters long.
I have sussed the problem by coding the following into my code - this is giving me what I need and I have tested all of the possibilities and it works as I need it to.
<td width="5px"> etc
to each field
|All times are GMT +1. The time now is 07:03 AM.|
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.