I'm trying to convert this to dwoo:
foreach($duplicates as $duplicate)
{
echo "<tr>";
foreach($column_list as $column)
{
if(@$duplicate{$column . "_diff"} == 1)
{
$id_is_different = '';
echo "<td style=\"background: #333333\" >". $duplicate{$column} ."</td>\n";
}
else开发者_如何学C
{
echo "<td>" . $duplicate{$column} ."</td>\n";
}
}
echo "</tr>";
}
I have this:
{foreach $duplicates duplicate}
<tr>
{foreach $column_list column}
<td{if $duplicate.$column.'_diff' == 1} style="background: #333"{/if}>{$duplicate.$column}</td>
{/foreach}
</tr>
{/foreach}
With the exception of: .$column.'_diff' on the 4th line, it works perfectly. any idea how i can add the suffix to the variable with dwoo?!?!
Thanks!
EDIT
I probably should have explained better.
Basically, what I'm doing is grabbing a list of column names from a mysql table, $column_list(using "SHOW COLUMNS FROM..."). Then doing another query to select the data, in that query, i'm matching data in each column to another table and adding a column with a prefix of "_diff" so if i have a column named "name" i also have a column "name_diff"(these columns are not in $column_list) that has a value of either 1 or 0. the 1 or 0 just signify weather or not the data matched in the other table. anyhow, The number of columns and column names are always changing so I can't really use any column names in the code. so....
with dwoo, {$duplicate.$column} would be something like $duplicate['name']; and what i'm trying to do is dynamically add the suffix "_diff" so i can change the background color of the cell... I know that was super confusing! I'm really bad at explaining things!
I'm afraid the only solution for now is to do the following :
{foreach $duplicates duplicate}
<tr>
{foreach $column_list column}
{$diffcol = cat($column '_diff')}
<td{if $duplicate.$diffcol == 1} style="background: #333"{/if}>{$duplicate.$column}</td>
{/foreach}
</tr>
{/foreach}
try this
{foreach $column_list column}
<td{if $duplicate.$column.last == 1} style="background: #333"{/if}>{$duplicate.$column}</td>
{/foreach}
精彩评论