results of a mysql query. i wanted to change the background image of
alternating rows in the table. i thought i could do this by defining
two different blocks in the template file and setting the current block
based on ( $thisRowNum % 2 ).
when the final table is displayed, all the "even" rows are displayed
before all the "odd" rows. in other words, the rows are not
interleaved. how can i get the rows to display properly alternating?
--------------------------
my template file 'searchResults. html' contains:
<table width="100%" border="0" cellpadding="0" cellspacing="5" >
<!-- BEGIN ENTRY_EVEN -->
<tr><td rowspan="3">{AU THOR}</td></tr>
<!-- END ENTRY_EVEN -->
<!-- BEGIN ENTRY_ODD -->
<tr><td rowspan="3" class="shadeDar ker2">{AUTHOR}</td></tr>
<!-- END ENTRY_ODD -->
</table>
--------------------------
my PHP code in 'searchAction.p hp' contains:
$template = new HTML_Template_I T( "./templates" );
$template->loadTemplatefi le( "searchResult.h tml", true, true );
$thisRowNum = -1;
while ( $row = mysql_fetch_arr ay( $result )) {
$thisRowNum++;
if ( $thisRowNum % 2 ) {
$currBlock = "ENTRY_ODD" ;
} else {
$currBlock = "ENTRY_EVEN ";
}
print "thisRowNum = $thisRowNum; currBlock = $currBlock; author
{$row["author"]}<< <br>\n";
$template->setCurrentBloc k( $currBlock );
$template->setVariable( "AUTHOR", $row["author"] );
$template->parseCurrentBl ock();
} // end while mysql_fetch_arr ay
$template->parse();
$template->show();
--------------------------
which produces this output:
thisRowNum = 0; currBlock = ENTRY_EVEN; author >>Boff, Leonardo<<
thisRowNum = 1; currBlock = ENTRY_ODD; author >>Galilea, Segundo<<
thisRowNum = 2; currBlock = ENTRY_EVEN; author >>Manning, Brennan<<
thisRowNum = 3; currBlock = ENTRY_ODD; author >>Nolan, Albert<<
thisRowNum = 4; currBlock = ENTRY_EVEN; author >>Segundo, Juan Luis<<
--------------------------
but the table is shown with the authors in the following order:
(ENTRY_EVEN) Boff, Leonardo
(ENTRY_EVEN) Manning, Brennan
(ENTRY_EVEN) Segundo, Juan Luis
(ENTRY_ODD) Galilea, Segundo
(ENTRY_ODD) Nolan, Albert
is there some buffer-flushing issue here?
thanks - bettyann