Categories > TinyButStrong general >

block-related question

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: michael
Date: 2004-09-07
Time: 03:59

block-related question

Hi

I want to display 8 rows - one for each of 7 days (plus another for a special day, public holiday) - using data from a table containing dayID & day (e.g. 1, Sun; 2, Mon; 3, Tues etc). I also want to use the same table data to populate a select. The select is also on each row, and the select should contain a pulldown containing all 8 days data. If I do the following, I get 8 table rows, but the contents of each select is just one value - first row is Sun.. second is Mon etc.

        <form action="" method="get" name="form">
            <table width="660" border="1" cellspacing="2" cellpadding="0">
                <tr>
                    <td><select name="day1" size="1" onChange='copy(a, b)'>
                            <option selected value="0">- select -</option>
                            <option value="[days.dayID;block=tr]">[days.day]</option>
                        </select>
                    </td>
                    <td><select name="zone1begin" size="1">
                            <option value="0:00">midnight</option>
                            <option value="0:30">12:30am</option>
                        </select></td>
                    <td><select name="b" size="1">
                            <option selected value="0">- select -</option>
                        </select></td>
                    <td><select name="zone1end" size="1">
                            <option value="0:00">midnight</option>
                            <option value="0:30">12:30am</option>
                        </select>
                    </td>
                </tr>
            </table>
        </form>


if I change the

  <option value="[days.dayID;block=tr]">

to

  <option value="[days.dayID;block=option]">

I get one row with the select containing all the day values.

I can see why this happens in both cases. I wonder how to change the code to make it so I can realise what I am aiming for.

Regards

Michael.
By: michael
Date: 2004-09-07
Time: 04:17

Re: block-related question

Hi Skrol29

I remember what you recently said in a related issue (in response to "onsection question"):

> There is a tip that enables you to use only one block name
> and only one MergeBlock call : add the parameter p1='' in
> the block definitions. Then they will considered as sub-block,
> and query will be recalled for each of them.

OK I tried that, and I think I got a solution but I needed to create another MergeBlock.

Here is the new HTML:

<form action="" method="get" name="form">
            <table width="660" border="1" cellspacing="2" cellpadding="0">
                <tr>[days-row;block=table]
                    <td><select name="day[days.#]" size="1" >
                            <option selected value="0">- select -</option>
                            <option value="[days.dayID;block=option;p1='']">[days.day]</option>
                        </select>
                    </td>

and here is the php

$TBS = new clsTinyButStrong;
$TBS->LoadTemplate('time-select.htm');

// for "rows"
$TBS->MergeBlock('days-row', $connection_id, 'SELECT * FROM days') ;

//for populating selects
$TBS->MergeBlock('days', $connection_id, 'SELECT * FROM days') ;

mysql_close($connection_id);

$TBS->Show() ;

You were right about p1=''  is the key, but I needed to create a duplicate MergeBlock (with different name) to get the desired result. If I used only one MergeBlock, I got the same result as before (i.e. 8 rows but only one day in each select instead of 8).

Any comment or suggestion is welcome.

Thanks alot.

Best regards

Michael.
By: Skrol29
Date: 2004-09-08
Time: 20:11

Re: block-related question

Hi,

Because you have one set of feeded lists for each row, I suggest that you first merge the lists, and then the rows.

If you have several blocks to merge (several lists plus the rows) you can first retrieve your data into an array using PHP, and then merge the blocks using the same array.