perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Derrick Spell <>
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 

	<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>
	[$ endwhile $]

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?


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message