[英]Use data from an SQL query, but don't display column in table
EDIT: If I use $colName instead of $colname, I'd have no issues. 编辑:如果我使用$ colName而不是$ colname,则不会有任何问题。 Stupid, simple fix. 愚蠢的简单解决方法。
I have a query pulling 6 columns from multiple tables. 我有一个查询从多个表中提取6列。 The final column is necessary to be used in a dynamic URL I'm generating, but I don't want that column to display on my table. 最后一列必须在我生成的动态URL中使用,但是我不希望该列显示在我的表上。 How can I hide it/make it not show up? 如何隐藏它/使其不显示? Is there a way to call the data, but not use it in my table? 有没有一种方法可以调用数据,但不能在表中使用它?
Query ex: 查询前:
SELECT a, b, c, d, e, exTable.f as CID
FROM table exTable
JOIN <other tables>
WHERE stuff happens
Table (you can see that my header row will hide fine, but the content won't): 表(您可以看到我的标题行可以隐藏,但内容不会隐藏):
<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') {
愚蠢的简单解决方案:使用$ colName代替$ colname。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.