perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derrick Spell <derricksp...@cdmplus.com>
Subject Apparent Nesting Problem
Date Mon, 25 Apr 2005 19:36:59 GMT
Greetings, All!

I apparently have some sort of control statement nesting problem in my 
code, but I can't seem to find it.  Perhaps a few extra sets of eyes 
can help...

This segment is supposed to loop through the result set of a database 
query and output the results in a table, highlighting the odd numbered 
rows:

	<table width="100%" border="0">
	[$ while $dref = $sth->fetchrow_hashref() $]
		[$ if ($background eq 1) $]<tr style="background: #ccc;">[$ else 
$]<tr>[$ endif $]
		[- $background = !$background -]
		  <form method="post" action="#">
		  	[$ foreach $key (keys %$dref) $]
				<td>[+ $dref->{$key} +]<input type="hidden" name="[+ $key +]" 
value="[+ $dref->{$key} +]"></td>
			[$ endforeach $]
			<td><input type="submit" name="addToCart" value="Add to Cart"></td>
		  </form>
		</tr>
	[$ endwhile $]
	</table>

It works if I omit the if statement to handle background coloring.  
Right now I get the error that '/table' doesn't match starttag 'tr', 
which makes me think it is printing both opening <tr> tags.  If I omit 
the second <tr> (i.e. leave only whitespace between the else and endif) 
then I get an unstructured forward jump error.  Can anyone see what I'm 
missing here?

-Derrick



---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-unsubscribe@perl.apache.org
For additional commands, e-mail: embperl-help@perl.apache.org


Mime
View raw message