Categories > TinyButStrong general >

Help with multidimension array

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: simkess
Date: 2007-10-01
Time: 20:44

Help with multidimension array

I don't get it..

array {
  ["id"]=>
  array(17) {
    [0]=>
    string(2) "17"
    [1]=>
    string(2) "16"
  }
  ["customer_id"]=>
  array(17) {
    [0]=>
    string(1) "1"
    [1]=>
    string(1) "1"
  }
  ["date_sent"]=>
  array(17) {
    [0]=>
    NULL
    [1]=>
    string(10) "0000-00-00"
  }
  ["date_created"]=>
  array(17) {
    [0]=>
    string(10) "2007-10-01"
    [1]=>
    string(10) "2007-10-01"
  }
  ["link"]=>
  array(17) {
    [0]=>
    string(19) "data/xyy/ss.html"
    [1]=>
    string(19) "data/zerd/123.html"
  }
  ["subject"]=>
  array(17) {
    [0]=>
    string(0) "HELO!"
    [1]=>
    string(0) "GOODBYE"
  }
}

I want an output like this:

<tr>id</tr>
<tr>subject</tr>

...


Thx for help
By: TomH
Date: 2007-10-01
Time: 22:26

Re: Help with multidimension array

TBS is aimed at database query result sets -- which means my simple answer is that your data array is not the conventional structure one would get from a db query. (That doesn't mean it is not possible to use that structure, just that I am not used to using that style.)

A db query would give result like this using your  (abbreviated) data
$data =
Array (
    [0] => Array
        (
            [id] => 17
            [subject] => HELO!
        )
    [1] => Array
        (
            [id] => 16
            [subject] => GOODBYE
        )
)

Where each record has the id, subject, etc as a key.

With that data, your TBS template would look like...
<table width border="1">
<data>
<tr><td>id</td><td>[blk.id;block=data]</td></tr>
<tr><td>subject</td><td>[blk.subject]</td></tr>
</data>
</table>

Not an exact answer to your question, but I hope it helps,
TomH

PS next time if you have actual TBS php and template code that is not working - then it is easier for us to help if you post the code for us to see what you have actually done.