現在、次のテーブル構造を含むデータベースを使用しています。
round | current
===============
P | 0
1 | 1
2 | 0
3 | 0
4 | 0
A | 0
current が 1 であるすべての行に対して「明るい円」を出力する PHP コードを作成しようとしています。したがって、上記の表では、電流が 1 であるため 1 が点灯します。他のラウンドの残りは灰色の円で表されます。
ここに例を含めました: http://i.imgur.com/GYvUdii.png
しかし、私が今抱えている問題は、私のコードがこれを出力していることです: http://i.imgur.com/Q41kBnM.png上記のように単一の行を返すことだけを意図している場合。
ここに HTML 出力を含めました: http://jsfiddle.net/pn8BW/
これは、私が現在使用している PHP/MySQL です。私はこれに1時間取り組んでいるので、これについての助けをいただければ幸いです:-(:
<?php
$sql = "SELECT * from ts_rounds";
$result = $pdo->query($sql);
$circleSize = array ('circle_small', 'circle');
$rounds = '';
foreach ($result as $row) {
switch ($row['round']) {
case 'P':
$rounds .= '<div id="r0" class="'.$circleSize[$row['current']].'"><h3>P</h3></div>';
case '1':
$rounds .= '<div id="r1" class="'.$circleSize[$row['current']].'"><h3>1</h3></div>';
case '2':
$rounds .= '<div id="r2" class="'.$circleSize[$row['current']].'"><h3>2</h3></div>';
case '3':
$rounds .= '<div id="r3" class="'.$circleSize[$row['current']].'"><h3>3</h3></div>';
case '4':
$rounds .= '<div id="r4" class="'.$circleSize[$row['current']].'"><h3>4</h3></div>';
case 'A':
$rounds .= '<div id="r5" class="'.$circleSize[$row['current']].'"><h3>A</h3></div>';
}
}
echo $rounds;
?>