PHP、Dwoo - 变量
我正在尝试将其转换为 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
{
echo "<td>" . $duplicate{$column} ."</td>\n";
}
}
echo "</tr>";
}
我有这个:
{foreach $duplicates duplicate}
<tr>
{foreach $column_list column}
<td{if $duplicate.$column.'_diff' == 1} style="background: #333"{/if}>{$duplicate.$column}</td>
{/foreach}
</tr>
{/foreach}
除了第四行的 .$column.'_diff' 之外,它工作得很好。知道如何使用 dwoo 将后缀添加到变量吗?!?!
谢谢!
编辑
我可能应该解释得更好。
基本上,我正在做的是从 mysql 表 $column_list 中获取列名列表(使用“SHOW COLUMNS FROM...”)。然后执行另一个查询来选择数据,在该查询中,我将每列中的数据与另一个表匹配,并添加一个前缀为“_diff”的列,因此如果我有一个名为“name”的列,我也有一列“name_diff”(这些列不在 $column_list 中),其值为 1 或 0。1 或 0 仅表示天气或不与其他表中匹配的数据。无论如何,列数和列名总是在变化,所以我不能真正在代码中使用任何列名。所以....
对于 dwoo,{$duplicate.$column} 会类似于 $duplicate['name'];我想做的是动态添加后缀“_diff”,这样我就可以更改单元格的背景颜色......我知道这非常令人困惑!我真的不擅长解释事情!
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
{
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
恐怕目前唯一的解决方案是执行以下操作:
I'm afraid the only solution for now is to do the following :
试试这个
try this