I'm currently working with a database that contains the following table structure:
round | current
===============
P | 0
1 | 1
2 | 0
3 | 0
4 | 0
A | 0
I have been trying to write PHP code that will output "a lit up circle" for every row in which current is one. So with the table above, 1 would be lit up because current is 1 - the rest of the other rounds would be represented by grey circles.
I've included an example here: https://i.sstatic.net/uUgkY.png
However the difficulty I'm having right now is that my code is outputting this: https://i.sstatic.net/JGbkO.png when its only meant to be returning a single row as above.
I've included the HTML output here: http://jsfiddle.net/pn8BW/
This is the PHP/MySQL I'm using now. Would appreciate some help on this because I've been working at it for an hour :-(:
<?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;
?>