要在HTML-PHP表的整列中放入相同的值吗
我想在整个表的一列中输入相同的值 这张桌子看起来像这样 假设,我想为所有Lvl7设置社区所有者的身份 这是表格代码要在HTML-PHP表的整列中放入相同的值吗,php,html,Php,Html,我想在整个表的一列中输入相同的值 这张桌子看起来像这样 假设,我想为所有Lvl7设置社区所有者的身份 这是表格代码 <table class="table" id="myTable"> <thead> <tr class="header"> <th width="60%"></th> <th width="20%"></th>
<table class="table" id="myTable">
<thead>
<tr class="header">
<th width="60%"></th>
<th width="20%"></th>
<th width="20%"></th>
</tr>
</thead>
<?php
$query = $config->prepare("SELECT playerName, playerLevel FROM `playerdata` WHERE playerLevel = 7 ORDER BY playerName DESC");
$query->execute();
while($data = $query->fetch())
{
echo "<tr><td>".$data['playerName']."</td>";
echo "<td>".$data['playerLevel']."</td></tr>";
}
?>
</table>
如何将该值作为此表的社区所有者。
我在所有级别都有类似的表格
我不知道如何使用and来回显第三列,或者为Status列中的所有行打印相同的值。
当我试图编码时,它只将值Community Owner打印到表的最后一行
备注:-我是这方面的新手,非常感谢任何类型的帮助。while($data=$query->fetch())
while($data = $query->fetch())
{
echo "<tr><td>".$data['playerName']."</td>";
echo "<td>".$data['playerLevel']."</td>";
switch ($data['playerLevel'])
{
case 7:
echo "<td>Community owner</td></tr>";
break;
default:
echo "<td>Not defined</td></tr>";
break;
}
}
{
echo“$data['playerName]”;
echo“$data['playerLevel']”;
开关($data['playerLevel']))
{
案例7:
呼应“社区业主”;
打破
违约:
回声“未定义”;
打破
}
}
//将数据['playerLevel']从switch语句中的原始post更改为$data['playerLevel'],它起作用了:DHello,状态值,它在哪里?它在数据库里吗?因为您在查询时没有选择它?你能详细解释一下你想从哪里获取状态值吗?不,它不在数据库中,我尝试使用switch语句,但因为我使用while语句来提供值,如playername和playerlevel,所以我不能真正使用该语句。我需要手动写入状态,比如使用foreach语句或类似的东西。很抱歉,迟到了,您得到了我的答案,它会起作用,但我建议将所有信息保存到数据库中。非常感谢,我使用了switch语句,但我使用的方式不同,我没有提到$data,所以它只显示默认情况。