Categories > TinyButStrong general >

sending arrays in MergeBlock, need some help

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Kwakhed
Date: 2008-03-02
Time: 03:33

sending arrays in MergeBlock, need some help

I have a problem with sending over arrays in MergeBlock,  I am altering an admin page to display dates seperately by year I am sending over the arrays like this:

$TBS->MergeBlock('data','array', 'thedata');
$TBS->MergeBlock('datasub', 'array', 'thedata[%p1%][year]');            $TBS->Show();

the corresponding dates are array thedata[x] and the dates are in thedata[x][year].  The problem is once i made alterations to the script the TBS page loads a blank page.  I don't think the error is part of my php code because I wrote something similar to this in another alteration to the same page but this time the tbs page shows nothing.  If someone could help me with this it would be very helpful

By: Kwakhed
Date: 2008-03-02
Time: 08:44

Re: sending arrays in MergeBlock, need some help

Well I've made some progress but now I get this error printed literally hundreds of times over and over again in the page
TinyButStrong Error when merging block [datasub] : invalid query 'thedata[1][year]' because item 'year' is neither an Array nor an Object. Its type is 'string'.
By: Skrol29
Date: 2008-03-02
Time: 17:38

Re: sending arrays in MergeBlock, need some help

Hi,

And what is the HTML for this merging?
By: Kwakhed
Date: 2008-03-02
Time: 21:30

Re: sending arrays in MergeBlock, need some help

<td><a href="default.php?page=invoice&amp;invoiceid=[datasub.id]&amp;userid=[datasub.userid]">[datasub.date;frm='mmmm dd,yyyy';block=tr;p1=[data.$]]</a></td>
I am trying to display dates inside the db by year

this is the php code I have:
                $TBS->LoadTemplate('pages/invoicebymonth.tbs');
               
                        // query to get dinstinct Year from db and join invoices and invoice details
                        $query="SELECT    invoices.manualdate,
                                    users.id
                                    FROM invoices, users
                                    WHERE users.id=invoices.user_id
                                    AND users.id = '$userid'
                                    ORDER BY invoices.manualdate desc";
                       
                        $result=mysql_query($query);
                        // if results has value
                        if ($result){
                            // puts the results into $nums as an array
                            $nums=mysql_num_rows($result);
                                if ($nums>=1) {
                                    // while there is values to go into $data from array $results
                                    while($data = mysql_fetch_array($result)){
                                        $dateyear[] = date('Y', $data[0]);
                                    } // while
                                } else {
                                exit('no data available');
                                }
                        } else {
                        exit ('could not execute database query');
                        }
                        $subyear = array_unique($dateyear);
                        $manualyear = array_merge($subyear);
                        //print_r($manualyear);
                           
                for ($i = 0; $i < count($manualyear); $i++) {
                    $currentyear = $manualyear[$i];
                    $thedata[$i] = $currentyear;
                    $query="select id,manualdate from invoices where user_id = '$userid' order by manualdate desc";
                    $results=mysql_query($query) or print mysql_error();
                    if ($results){
                        $nums=mysql_num_rows($results);
                        if ($nums>=1) {
                            while($data=mysql_fetch_array($results)){
                                if (date('Y', $data[1]) == $currentyear) {
                                    $thedata[$i]['year'] = array('id' => $data[0],
                                                            'date' => $data[1],
                                                            'userid' => $userid);
                                }
                            }   
                        } else {
                        exit('no data available');
                        }

                    } else {
                exit ('could not execute database query');
                }

                } // for loop
                //print_r($thedata);
                $now = time();
                $TBS->MergeBlock('data','array', 'thedata');
                $TBS->MergeBlock('datasub', 'array', 'thedata[%p1%][year]');                       
                $TBS->Show()