I am not sure what you want to use TMPL_IF for but I think you have a classic programming problem.
If I assume correctly, you have 365 days with X orders?
Days + Orders
I had the same problem with
Users + Posts
I solved it that way:
$select_posts = SELECT p_id, p_post, p_u_id FROM gb_posts ORDER BY p_u_id;
$select_users = SELECT u_id, u_name FROM gb_users ORDER BY u_id;
$result_posts = mysql_db_query$dbname, $select_posts, $connect;
$result_users = mysql_db_query$dbname, $select_users, $connect;
$row_posts = mysql_fetch_array$result_posts;
$outer = array;
while $row_users = mysql_fetch_array$result_users
$inner = array;
while $row_postsp_u_id == $row_usersu_id
$eintrag = substr$row_postsp_post, 0, 15;
array_push$inner, array
'p_id' = $row_postsp_id,
'eintrag' = $eintrag
;
$row_posts = mysql_fetch_array$result_posts;
array_push$outer, array
'u_id' = $row_usersu_id,
'u_name' = $row_usersu_name,
'inner' = $inner
;
$tmpl-setloop'outer', $outer;
$tmpl-pparse;
?
pre
? print_r$outer; ?
/pre
Template:
tmpl_loop name='outer'
bUser tmpl_var name='u_id' - tmpl_var name='u_name'/b br
tmpl_loop name='inner'
p_id tmpl_var name='p_id' - tmpl_var name='eintrag'br
/tmpl_loop
/tmpl_loop
Note: I had to program in COBOL this problems a lot. They are called "Gruppenwechsel" (Group change) in German. COBOL S*CKS!