Jump to content


Photo

Help restraining HTML table sizes


  • Please log in to reply
6 replies to this topic

#1 aaarrrggh

aaarrrggh
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 April 2006 - 06:09 PM

Hi,

I'm currently trying to display some php output inside a html table. All the data is printing just as I want, except that the table itself seems to resize and reshape according to what data comes out of php. Is there any way for me to force the table and all table cells to stay exactly the same size no matter what?

You can see the table I'm talking about by viewing this temporary site: [a href=\"http://www.itr.org.uk/home.php?page_id=tables.php&showtable=33\" target=\"_blank\"]http://www.itr.org.uk/home.php?page_id=tab...hp&showtable=33[/a]

As you can see right now, it doesn't look neat at all. Does anybody know how I can fix this?

#2 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 04 April 2006 - 06:18 PM

this is a HTML question so nothing to do with your PHP, but in a nutshell, you're drawing a different table for each footy team. if you drew one table and just used PHP to cycle through and draw the <tr>'s instead of the full <tables>, then you'll have a much better looking table:

<table>
   <tr>
      <td></td>
      <td></td>
   </tr>
   <tr>
      <td></td>
      <td></td>
   </tr>
</table>
instead of what you have right now:

<table>
   <tr>
      <td></td>
      <td></td>
   </tr>
</table>

<table>
   <tr>
      <td></td>
      <td></td>
   </tr>
</table>

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#3 gijew

gijew
  • Members
  • PipPipPip
  • Advanced Member
  • 240 posts
  • LocationCalifornia

Posted 04 April 2006 - 06:22 PM

Might want to think about throwing some <TD width="x"> in there as well for resizing.
I'm considered good looking in some countries

#4 aaarrrggh

aaarrrggh
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 April 2006 - 06:47 PM

Thanks guys. I did what redbull said, and it seems to be looking a lot better now.

Just out of interest, would using <TD width="x"> restrict the size of the table even when data comes through php that is too big for the table cell? Is there anyway to stop it from resizing?

This isn't a problem to me right now, but it's something I know I might need to know in the future. Thanks for the help once again :)

#5 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 04 April 2006 - 07:15 PM

[!--quoteo(post=361654:date=Apr 4 2006, 07:47 PM:name=aaarrrggh)--][div class=\'quotetop\']QUOTE(aaarrrggh @ Apr 4 2006, 07:47 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Just out of interest, would using <TD width="x"> restrict the size of the table even when data comes through php that is too big for the table cell? Is there anyway to stop it from resizing?
[/quote]

to an extent. holding a table column to a width would normally cause the info in the cells to continue on a new line, but depends.
if i was setting up a league table personally, i would change your code by removing the 'width' property from your football team name column but leaving the rest alone. you've set the width of the table to 420 or something and yet all your column widths don't add up to much more than 200. removing the width property from the largest column (ie, the team name) will at least prevent other problems in the future.

"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!

#6 aaarrrggh

aaarrrggh
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 April 2006 - 07:42 PM

[!--quoteo(post=361669:date=Apr 4 2006, 02:15 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 02:15 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
to an extent. holding a table column to a width would normally cause the info in the cells to continue on a new line, but depends.
if i was setting up a league table personally, i would change your code by removing the 'width' property from your football team name column but leaving the rest alone. you've set the width of the table to 420 or something and yet all your column widths don't add up to much more than 200. removing the width property from the largest column (ie, the team name) will at least prevent other problems in the future.
[/quote]

I tried removing the width property from the team column, and it's worked perfectly. Is that because this now becomes the most 'flexible' column, if you know what I mean? Like... any available empty space is allocated to this column first because there's no explicit 'width' property defined?

Is that why this works? Thanks for the help by the way, the tables are looking a lot better now :)

#7 redbullmarky

redbullmarky
  • Staff Alumni
  • Advanced Member
  • 2,863 posts
  • LocationBedfordshire, England

Posted 04 April 2006 - 08:14 PM

[!--quoteo(post=361682:date=Apr 4 2006, 08:42 PM:name=aaarrrggh)--][div class=\'quotetop\']QUOTE(aaarrrggh @ Apr 4 2006, 08:42 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
...Is that because this now becomes the most 'flexible' column, if you know what I mean? Like... any available empty space is allocated to this column first because there's no explicit 'width' property defined?...
[/quote]


basically, you got it in one. yep :)
"you have to keep pissing in the wind to learn how to keep your shoes dry..."

I say old chap, that is rather amusing!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users