以下代码通常显示2列,其中包含链接名称Engagement report
和Personal report
。
有些情况下,第二个超链接字段$ccP
为空,我希望该单元格也显示为空,而不是Personal report
请帮助实现这一目标。
while($row = mysql_fetch_array($login)){
$Report=$row['ReportName'];
$cc=$row['LinkEngagement'];
$ccP=$row['LinkPersonal'];
print "<tr class='alt'>
<td align='Left'>$Report</td>
<td align='Center'><a href='$cc' style='cursor:pointer' >Engagement report </a></td>
<td align='Center'><a href='$ccP' style='cursor:pointer' >Personal report </a></td>
</tr>";
}
print "</table>";
答案 0 :(得分:0)
检查$ccP
是否分配了某些内容,并且仅在打印时才打印。
if($ccP){
print "<td align='Center'><a href='$ccP' style='cursor:pointer' >Personal report </a></td>";
}
答案 1 :(得分:0)
while($row = mysql_fetch_array($login)){
$Report=$row['ReportName'];
$cc=$row['LinkEngagement'];
$ccP=$row['LinkPersonal'];
$ccPLink=(empty($ccp)) ? "" : $ccp ;
print "<tr class='alt'>
<td align='Left'>$Report</td>
<td align='Center'><a href='$cc' style='cursor:pointer'>Engagement report </a></td>
<td align='Center'><a href='$ccP' style='cursor:pointer'>$ccpLink </a></td>
</tr>";
}