Jump to content

Set colspan


xionhack

Recommended Posts

Hello. I am making some tables that are generated from some values in a database.

 

The is always 1 word in the top of the table (1st row) and then some values on the 2nd row. Some tables on the 2nd row have 3 columns, some 4, some 5, etc... How can I make the colspan value to be set automatically? Thanks!

Link to comment
https://forums.phpfreaks.com/topic/149330-set-colspan/
Share on other sites

You could do it by a series of isset's, empty's, or etc., depending on if it is an array or however you are doing it.

 

<?php
if (isset($variable1)) { echo "<TD COLSPAN=2>"; }
       else { echo "<TD>"; }
?>

 

Depends on how complex the application is, really.  I would look at my data organization, though, before proceeding.  If you have lots of values that aren't really related to each other (they don't have the same information), it may be more efficient to separate them into separate tables and organize the data better in that way.  I am not really sure what your data structure looks like, though.

Link to comment
https://forums.phpfreaks.com/topic/149330-set-colspan/#findComment-784207
Share on other sites

are you looking to always have one large row at the top of each table spanning all columns ?

 

Yes, that's what Im looking for!

 

you can either use a table header  <th> for this, or you can set the colspan to some arbitrary high number (higher than the possible number of columns) and it will just resize for whatever table size is appropriate

Link to comment
https://forums.phpfreaks.com/topic/149330-set-colspan/#findComment-784223
Share on other sites

are you looking to always have one large row at the top of each table spanning all columns ?

 

Yes, that's what Im looking for!

 

you can either use a table header  <th> for this, or you can set the colspan to some arbitrary high number (higher than the possible number of columns) and it will just resize for whatever table size is appropriate

 

When I make it a <th>, how can I set it in the middle and for the rest of the cells to merge with that one?

Link to comment
https://forums.phpfreaks.com/topic/149330-set-colspan/#findComment-784256
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.