Jump to content

Recommended Posts

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?
Link to comment
https://forums.phpfreaks.com/topic/6584-help-restraining-html-table-sizes/
Share on other sites

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:

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

[code]
<table>
   <tr>
      <td></td>
      <td></td>
   </tr>
</table>

<table>
   <tr>
      <td></td>
      <td></td>
   </tr>
</table>
[/code]
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 :)
[!--quoteo(post=361654:date=Apr 4 2006, 07:47 PM:name=aaarrrggh)--][div class=\'quotetop\']QUOTE(aaarrrggh @ Apr 4 2006, 07:47 PM) [snapback]361654[/snapback][/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.
[!--quoteo(post=361669:date=Apr 4 2006, 02:15 PM:name=redbullmarky)--][div class=\'quotetop\']QUOTE(redbullmarky @ Apr 4 2006, 02:15 PM) [snapback]361669[/snapback][/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 :)
[!--quoteo(post=361682:date=Apr 4 2006, 08:42 PM:name=aaarrrggh)--][div class=\'quotetop\']QUOTE(aaarrrggh @ Apr 4 2006, 08:42 PM) [snapback]361682[/snapback][/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 :)
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.