所以我想像
一样显示它Champion name
name of the column e.g. Q name of the spell - Surging Tides
the rest of spells for that champion
Next Champion etc.,
这是我现在显示冠军名称的方式
$champions = $conn->prepare("SELECT *
FROM champions
Where Patch_No = ?");
$champions->bind_param('s', $Patch_No);
$champions->execute();
$champions_result = $champions->get_result();
while($row = $champions_result->fetch_assoc()){
echo $row['Champion'].' '.$row['NumNotNull'].'<br>';
}
我无法想到用尽可能少的查询来做到这一点的简单方法。
这是另一个示例,它应该是什么样的
答案 0 :(得分:1)
$row
是一个关联数组,因此您可以使用foreach
遍历它并测试该列是否为空。
while($row = $champions_result->fetch_assoc()){
echo $row['Champion'].' '.$row['NumNotNull'].'<br>';
foreach ($row as $column_name => $column) {
if ($column_name == 'Champion' || $column_name == 'NumNotNull') {
continue; // These fields were already displayed above
}
if (!empty($column)) {
echo "$column_name $column<br>";
}
}
}