我的数据库中有一个名为 ts_rounds 的表,其结构如下
round | current
===============
P | 0
1 | 1
2 | 0
3 | 0
4 | 0
我试图<div>
在两种不同的条件下呼应某种安排:
当前值为 1,其余为 0
所有电流为0,多于一个电流值为1
一旦满足条件,我就想跳出 if 语句。
到目前为止,这是我的代码,第一个条件得到满足,但我无法满足第二个条件。
<div id="timeline">
<?php
$sql = "SELECT * from ts_rounds";
$result = $pdo->query($sql);
foreach ($result as $row)
{
if ($row["round"] == "P" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
';
}
else if ($row["round"] == "1" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
';
}
else if ($row["round"] == "2" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
';
}
else if ($row["round"] == "3" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
';
}
else if ($row["round"] == "4" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
</div>';
}
else if ($row["round"] == "A" && $row["current"] == "1") {
echo
'
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle"><h3>A</h3></div>
<hr id="line">
';
}
else {
$rounds = '
<div id="r0" class="circle_small">
<h3>P</h3>
</div>
<div id="r1" class="circle_small"><h3>1</h3></div>
<div id="r2" class="circle_small"><h3>2</h3></div>
<div id="r3" class="circle_small"><h3>3</h3></div>
<div id="r4" class="circle_small"><h3>4</h3></div>
<div id="r5" class="circle_small"><h3>A</h3></div>
<hr id="line">
';
}
}
?>
</div>