正在尋找一個解決方案,以下編碼位。如果數據庫字段爲空回顯「沒有」,如果有東西回顯「東西」
<?php
$nextfive_events = mysql_query("SELECT date_format(date, '%d/%m/%Y') AS formatted_date, title, location, regs FROM events WHERE status = 'ACTIVE'");
if(mysql_num_rows($nextfive_events) == 0) { echo "<p>No events coming up!"; } else {
echo "<table width=\"600\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" class=\"greywritinglight\" align=\"left\">
<tr align=\"center\">
<td>Date</td>
<td>Name</td>
<td>Location</td>
<td></td>
</tr>";
$x=1;
while($next_row = mysql_fetch_array($nextfive_events))
{
if($x%2): $rowbgcolor = "#FFFFFF"; else: $rowbgcolor = "#EEEEEE"; endif;
echo "<tr align=\"center\">";
echo "<td>" . $next_row['formatted_date'] . "</td>";
echo "<td>" . $next_row['title'] . "</td>";
echo "<td>" . $next_row['location'] . "</td>";
echo "<td><a href=\"regs/" . $next_row['regs'] . "\">Regs</a></td>";
echo "</tr>";
$x++;
}
echo "</table>";
}
?>
我想行echo "<td> <a href regs .....
要顯示的字的REG時有東西在數據庫中的「暫存器」。說如果該領域沒有任何東西,我希望它是空白的,而不是說Regs。
感謝
'。 (isset($ next_row ['regs'])|| empty($ next_row ['regs']))''nothing':'something'. – Alex 2015-02-11 23:33:03