Categories > TinyButStrong general >

Problema com array !

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Cavanha
Date: 2010-01-25
Time: 12:37

Problema com array !

Well folks come again count on the collaboration of you, I created an array including using an example of you to generate a table, with (5) and COLUMN (X) lines as the number of rows is defined by the user, as well using the TBS example mounts the table as expected, however, in (2) of the columns I would like to play the data within an input type = 'text' because precisanm be changed by the user, it would be easy to do this if the data were coming from a table of the database, however I can not do with array, I will pass the code in the hope you help me, now required.


 

Code PHP

$columns = array();
  
   for ($col=1;$col<=5;$col++) {
           if ($col = 1){$columns[$col] = 'BOLETO';};
        if ($col = 2){$columns[$col] = 'ANO';};
        if ($col = 3){$columns[$col] = 'SEM';};
        if ($col = 4){$columns[$col] = 'VENCIMENTO';};
        if ($col = 5){$columns[$col] = 'VALOR';};}
   
   for ($row=1;$row<=$F1_qtdex;$row++) {
     $record = array();
     for ($col=1;$col<=5;$col++) {
         if ($col = 1){$record[$columns[$col]] = '0'.$row.'N'.'1';};
        if ($col = 2){$record[$columns[$col]] = $F1_anobol;};
        if ($col = 3){$record[$columns[$col]] = $F1_sembol;};
        if ($col = 4){$record[$columns[$col]] = '';};
        if ($col = 5){$record[$columns[$col]] = $F1_vlnegoc / $F1_qtdex;};
     }
    $data[$row] = $record;
    //print_r($data[$row]);
   }

Code HTML

<table border="0" width="520" id="alter">
<thead>
<tr><td></td><td width="100" align="center">[c0.val;block=td]</td></tr>
</thead>
<tr class="dif">
          <td bgcolor="#FFD8B0" class="title-section"><div align="center">[r.$;block=tr]</div></td>
          <td bgcolor="#FFFFFF"><div align="center">[r.[c2.val;block=td]] </div></td>
        </tr>
      </table>

Code TBS

    $TBS->MergeBlock('c0,c1,c2',$columns);
    $TBS->MergeBlock('r',$data);


not really quite understand how the block was cast, however this close to what I need.
By: Skrol29
Date: 2010-01-26
Time: 23:20

Re: Problema com array !

Hi Cavanha,

Try this for your template:
<table border="0" width="520" id="alter">
  <thead>
    <tr>
      <td></td>
      <td width="100" align="center">[c0.val;block=td]</td>
      <td width="100" align="center">[c0;block=td;nodata]<!--this td is only there to have a correct table definition --></td>
    </tr>
  </thead>
  <tr class="dif">
    <td bgcolor="#FFD8B0" class="title-section"><div align="center">[r.$;block=tr]</div></td>
    <td bgcolor="#FFFFFF"><div align="center"><input name="vencimento[[r.$]]" type="text" value="[r.[c2.val;block=td;when [c2.$]=4]]"></div></td>
    <td bgcolor="#FFFFFF"><div align="center">[r.[c2.val;block=td;default]]</div></td>
  </tr>
</table>

This will display an <input> tag for column number 4.
Data entered in input zone by users can be retrieved in PHP using the variable $_REQUEST['vencimento'] which should be a PHP array.

I hope that helps,
By: Cavanha
Date: 2010-01-27
Time: 10:47

Re: Problema com array !

Skrol29 Again thanks for your help.