I'm trying to build a dynamic table that will have varying amounts data.
I've got it working to a point, but I'm at a block.
I want the row number to always be 10 max.
For example, I may have 3 cols of 10 rows and the last col only has 4 rows worth of data. I will need to fill those cells with .
The amounts of cols will vary depending on the users query.
It would have to be completely dynamic.
Have you built something like this before?
I could use your incite. I have the feeling that it's right there on the tip of my brain. I hope I explained this clear enough.
Thanks,
Don
Dynamic table
Moderator: General Moderators
Does each piece of data have to be in its own cell of the same table?
I solved such columnizing before byt taking the amount of data and divide by max-rows to find out how many columns, then make a column-loop, and in each column create yet another table with a single column and the amount of rows, in the last main column you just add as many rows as there is data left without the need for whitespacing empty cells..
I solved such columnizing before byt taking the amount of data and divide by max-rows to find out how many columns, then make a column-loop, and in each column create yet another table with a single column and the amount of rows, in the last main column you just add as many rows as there is data left without the need for whitespacing empty cells..
- dstefani
- Forum Contributor
- Posts: 140
- Joined: Sat Jan 11, 2003 9:34 am
- Location: Meridian Idaho, USA
I guess I answered my own question.
I don't know if I'll need to worry about empty cells right now, but here's what I came up with for building a spreadsheet type of table in PHP.
This is not generated from MySQL yet, but you can probably see where I'm going with this. I built this from scratch to excercise my brain, it was fun. Still a rookie, but working on it.
- Don
I don't know if I'll need to worry about empty cells right now, but here's what I came up with for building a spreadsheet type of table in PHP.
This is not generated from MySQL yet, but you can probably see where I'm going with this. I built this from scratch to excercise my brain, it was fun. Still a rookie, but working on it.
- Don
Code: Select all
<?
$total_cells = 500;// would be recordset
$row_count = 10; // rows for my table
$col_count = $total_cells / $row_count; // cols I'll have
print "<table cellpadding="4" border=1>\n";
$row_incrementer = 1;
$col_lable = 1;
for($r = 1; $r <= $row_count; $r++)// build rows
{
print "<tr>\n";
for($c = 0; $c < $col_count; $c+=10)// build cols
{
print "<td>$col_lable</td>";
$col_lable+=10;
}
print "</tr>\n";
$row_incrementer++; // need a int to add to my next row
$col_lable = $row_incrementer;// my row increments by 1 each time through
}
print "</table>";
?>