编辑:如果我使用$ colName而不是$ colname,则不会有任何问题。愚蠢的简单解决方法。
我有一个查询,从多个表中提取6列。最后一列对于在我生成的动态URL中使用是必需的,但是我不希望该列显示在我的表上。如何隐藏它/使其不显示?有没有一种方法可以调用数据,但不能在表中使用它?
查询前:
SELECT a, b, c, d, e, exTable.f as CID
FROM table exTable
JOIN <other tables>
WHERE stuff happens
表格(您可以看到我的标题行可以很好地隐藏,但内容不会隐藏):
<table>
<thead>
<tr>
<th class="header"><strong>A</strong></th>
<th class="header"><strong>B</strong></th>
<th class="header"><strong>C</strong></th>
<th class="header"><strong>D</strong></th>
<th class="header"><strong>E</strong></th>
<th class="header" style="display:none"><strong>F</strong></th> <!-- THIS WORKS -->
</tr>
</thead>
<tbody>
<?
foreach($tableData as $row)
{
echo "<tr>";
foreach($tableColNames as $colName)
{
if ($colname=='CID') {
echo "<td style='display:none'>" . $row[$colName] . "</td>"; <!-- THIS DOES NOT -->
}
elseif ($colName=='e') {
echo "<td><a href='http://my.url.here/".$row[CID]."_Document.pdf' target='_blank'>" . $row[$colName] . " </a></td>";
}
else {
echo "<td>" . $row[$colName] . "</td>";
}
}
echo "</tr>";
}
?>
</tbody>
</table>
您有错别字:$colname
应该是$colName
。
if ($colname=='CID') {
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句