By: David Christensen
Date: 2004-04-02
Time: 22:57
|
n number of columnsI cannot seem to figure out how to display a dynamic number of columns. I tried using a variation of the "serial" format, but I cannot seem to get the table to have a dynamic set of columns.
Is this because the rows are defined first? My objective is to have a conditional display that shows either 8, 15, (multiples of 7 there after) columns depending on whatever the user selects from a form input. Thanks, Dave C. |
|||
By: David Christensen
Date: 2004-04-02
Time: 23:16
|
Re: n number of columnsNeed to add another wrinkle to the problem. The number of rows is also dynamic. I could have 2 or more depending on the data returned.
So to put it in DB terms, the rows are the record sets, and the columns are the fields. If a user desires more details, the number of columns can grow. If the user filters the search, the number of rows reduces. Thanks again, Dave C. |
|||
By: Skrol29
Date: 2004-04-03
Time: 01:06
|
Re: n number of columnsHi,
Someting like this should work: HTML:
We assume that $col_list is an array with the column names, and $recset is an opened recordset ressource. PHP:
|
|||
By: David Christensen
Date: 2004-04-03
Time: 02:23
|
Re: n number of columnsI should have been more specific in what I was using for data sources.
I'm actually using multi-deminsional arrays to populate the rows: 1st row: $days[] = array('name' => "Monday"); 2nd row: $jobs[] = array('name' => $somedata); The first field in row 1 is blank. The first field in row2 displays a location associated with the $jobs array. The "location" is also an array similar to $days[] and fills column 1, starting at row 2. The $jobs[] array fills column 2 to n, with $somedata. Thanks for your help, Dave |
|||
By: David Christensen
Date: 2004-04-03
Time: 02:29
|
Re: n number of columnsHere's an example of what it should look like:
HTML:
|
|||
By: Skrol29
Date: 2004-04-03
Time: 02:40
|
Re: n number of columnsI don't see how you retrieve the job data for a given couple of location+dow (date of work ?)
Hav you the data for all cells? |
|||
By: David Christensen
Date: 2004-04-03
Time: 02:44
|
Re: n number of columnsI've almost got it:
HTML:
PHP:
|
|||
By: David Christensen
Date: 2004-04-03
Time: 02:47
|
Re: n number of columnsThe problem I'm having now is, all the data is for the first locaiton. So it looks like:
location0 data[location0][0] data[location0[1] ... data[location0[N] location1 data[location0][0] data[location0[1] ... data[location0[N] ... locationN data[location0][0] data[location0[1] ... data[location0[N] It's not looping the "serial;td" (not right syntax I know) either at the right point, or I'm missising something still. Thanks again! |
|||
By: Skrol29
Date: 2004-04-03
Time: 02:59
|
Re: n number of columnsYou've forgoten to initialize $job_info before the $count loop.
|
|||
By: David Christensen
Date: 2004-04-03
Time: 03:09
|
Re: n number of columnsinit'ing the $job_info array didn't seem to help. I'm still getting the same output, which doesn't make sense by the way!
Here's the new PHP code:
Thanks again, I'm lost! |
|||
By: David Christensen
Date: 2004-04-03
Time: 03:49
|
Re: n number of columnsIn my many tries, I thought I'd just prepend the location to the $job_info[] array. Then, I can treat everyting as just rows of data from one array. Then just MergeBlock for each loop of $x:
No joy! All the row are the same data. Location0 Location0[Day0] Location0[Day1] ... Location0[DayN] PHP:##################################### # Merge the days array (from conf file) into template ### $temp = array('name' => " "); array_unshift($days, $temp); $TBS->MergeBlock('day',$days); for ($x=0; $x < count($sites); $x++) { $job_info[] = $sites[$x]; for ($count = 0; $count < $weeks; $count++) { $job_info[] = array('name' => $sites[$x]['name'] . "[Day$count]"); #print "TEMP: " . $sites[$x]['name'] . "[Day$count]<br>\n"; } #$TBS->MergeBlock('job',$job_info); $TBS->MergeBlock('site',$job_info); $job_info = array(); } $TBS->Show();
I can't seem to get it right. I'm still lost! |
|||
By: Skrol29
Date: 2004-04-03
Time: 18:27
|
Re: n number of columnsHi,
Your technic can't work because a block can be merged only once. And in your main loop you have coded a MergBlock(), it works only the first time becasue afte there is no block definition left. I have developped a web application that does quite the same as you're tring to do. Ecxept that in my application, I haven't an array that has an item for each cell. Here is what I suggest to you: HTML:
PHP:
When you have this, you should see the table with the correct number of rows and columns, and each cell is feeded with [data_dX_sY]. Then, in PHP, you add a double loop X,Y that replaces all strings "[data_dX_sY]" in $TBS->Source with the content you wish. It worked fine for me. |
|||
By: NeedBeans
Date: 2004-04-05
Time: 10:59
|
Re: n number of columnsYou should add this solution to the examples page, because I also spend quite some time in this problem. And there is no use in inventing the wheel again, if we already have a fine solution
Mike |
|||
By: Skrol29
Date: 2004-04-06
Time: 16:37
|
Re: n number of columnsYep, that's a good idea.
I'm going to replace the "programmed loop" example. |
|||
By: David Christensen
Date: 2004-04-09
Time: 01:55
|
Re: n number of columnsI'm not sure I follow your PHP completely. You have the "$days" array in both the 'day_title' MergeBlock as well as the 'day_cell' MergeBlock statements. Are you implying that I should just append my 'day_cell' data the the "$days" array?
Like I said, I'm still lost. I also looked at the "programmed loop" but it didn't look any different. Thanks again! |
|||
By: Skrol29
Date: 2004-04-09
Time: 16:31
|
Re: n number of columnsDon't look at the "programmed loop" example, it has nothing to do with your problem. I just said, I'll swap this example with a future "dynamical column" example.
You don't have to append day_cell into $days. Try the code I've sent sent (not tested) and look step by step what the PHP code does. Your Html Table has 1 row with date titles followed by several rows with date values. Because of Html Table structure, you first have to create the dynamic columns in 2 times: 1 for titles, and 1 for preparing rows. Look at a standard table structure and you'll undsertand why it can't be one in one shot. |
|||
By: Skrol29
Date: 2004-04-09
Time: 16:31
|
Re: n number of columnsDon't look at the "programmed loop" example, it has nothing to do with your problem. I just said, I'll swap this example with a future "dynamical column" example.
You don't have to append day_cell into $days. Try the code I've sent sent (not tested) and look step by step what the PHP code does. Your Html Table has 1 row with date titles followed by several rows with date values. Because of Html Table structure, you first have to create the dynamic columns in 2 times: 1 for titles, and 1 for preparing rows. Look at a standard table structure and you'll undsertand why it can't be one in one shot. |
|||
By: David Christensen
Date: 2004-11-12
Time: 04:00
|
Re: n number of columnsI've finally figured out what you were talking about. Hey, it only took my 7 months! j/k.
My problem now is I'm trying to also do 'x' number of rows of my 'n' columns. So basically it is a dynamic matrix. Is this possible? I've tried:
For whatever reason it spans columns, but only shows 1 row. |
|||
By: Skrol29
Date: 2004-11-13
Time: 01:49
|
Re: n number of columnsHello David,
I don't understand why you have 2 blocks 'client' and 'policy'. |
|||
By: David Christensen
Date: 2004-11-13
Time: 01:55
|
Re: n number of columnsI may be doing it wrong. I was just trying all different things to get it to do what I wanted. My desire is to have both columns and rows be dynamic. Basically, the rows are client data and the columns designate the start/end dates to query.
So depending on what data is returned based on the start/end date, that will dictate how many clients are returned and the number of columns. |
|||
By: CWL
Date: 2004-11-24
Time: 16:40
|
Re: n number of columnsHi Skrol29,
Have you finally put an example of dynamicall column ? I can't find it. Because, I don't understand theses lines :
What is data_d ? An Array ? and
|
|||
By: CWL
Date: 2004-11-24
Time: 17:47
|
Re: n number of columnsit's fine, I understood
Actually, I try to resolve the following problem : the first header line had 2 columns and the 2 header line had 4 columns. I have to find the solution to merge the columns of the 1st line to have a clear table... |
|||
By: Skrol29
Date: 2004-11-24
Time: 17:53
|
Re: n number of columns> Have you finally put an example of dynamicall column ?
Not yet, sorry. It's on the ToDo. |
|||
By: David Christensen
Date: 2004-11-30
Time: 16:06
|
Re: n number of columnsI still cannot get this to work properly. You asked before why I have 2 blocks, it is because I was following your example in a previous post in this thread (2004-04-03.) I can get some output to fill all the columns and rows using this technique, but it shows incorrect data. The first column (client name) is displayed correctly. The other columns only seem to populate when I place the MergeBlock within a final loop.
To make things more complicated, I am using a complex array with 2 subkeys:
This is because each row is specific to the $client and each column is specific to the $month. "failures" is the specific data for that client/month to display in each cell. If I loop through the clients, then loop through the months, I can get something to fill the table if I place the MergeBlock in the clients loop:
with the template looking like:
|
|||
By: Skrol29
Date: 2004-12-01
Time: 02:45
|
Re: n number of columnsHello,
Can you draw what structure of data you have, and what kind of Html display you want to have. |
|||
By: David Christensen
Date: 2004-12-01
Time: 19:45
|
Re: n number of columnsI'm not sure I understand your last post? I have a table, first column is client name. Columns 1 - x contain data for the client on a monthly basis. So there will be up to 12 columns. Each is row displayed exactly the same just adjusting data for each client.
Depending on the criteria for the search, will determine what will be displayed as 1 - x (up to 12) columns and 1 - y (clients) rows. My previous post show an example of the template I am using. |
|||
By: Skrol29
Date: 2004-12-01
Time: 23:47
|
Re: n number of columnsHello,
I'm asking the structure of you data because I fill I miss some information. For example, I can't see where is stored the name of the client. Now you say it is in a table. So I guess the 'client' block is merged with a query on that table. But what about the id of the client? Where does the variable $client come from, and what does it store ? I'm not sure to have all the pieces. Did you choose to build $data_arr this way or do you have to? Here is an example of solution that may help: PHP:
HTML:
|
|||
By: David Christensen
Date: 2004-12-02
Time: 00:59
|
Re: n number of columnsI'm sorry. I was the one who was confused. The raw data is stored in a PIPE delimited file/directory structure. Each directory is client based and each file is date based. So that is why I'm using an array to populate the template
|