这是我的代码:
echo "<td>" . $row4['CMUSERID'] . "</td>";
echo "<td>" . $row4['CMCLAS'] . "</td>";
echo "<td>" . $row4['CMRACE'] . "</td>";
echo "<td>" . $row4['CMGEND'] . "</td>";
echo "<td>" . $row4['CMSTRE'] . "</td>";
echo "<td>" . $row4['CMDEXT'] . "</td>";
echo "<td>" . $row4['CMCONS'] . "</td>";
echo "<td>" . $row4['CMWISD'] . "</td>";
以下是显示结果的页面链接:
http://oge.sytes.net/zetzer/includes/characters.php
如何修改我的PHP代码以从显示中消除PlayerClass和PlayerRace,所以如果他们没有选择一个类或种族,它会显示为空?我无法在数据库中更改它,因此必须在php显示中替换它
答案 0 :(得分:1)
echo "<td>" . $row4['CMUSERID'] . "</td>";
echo "<td>";
echo $row4['CMCLAS'] == "PlayerClass" ? " " : $row4['CMCLAS'];
echo "</td>";
echo "<td>";
echo $row4['CMRACE'] == "PlayerRace" ? " " : $row4['CMRACE'];
echo "</td>";
echo "<td>" . $row4['CMGEND'] . "</td>";
echo "<td>" . $row4['CMSTRE'] . "</td>";
echo "<td>" . $row4['CMDEXT'] . "</td>";
echo "<td>" . $row4['CMCONS'] . "</td>";
echo "<td>" . $row4['CMWISD'] . "</td>";
您可能希望将“
”替换为您喜欢的任何内容。