I am trying to infer information from my db through a while loop. I want the results displayed as follows:
First Name Last Name - First Name Last Name - First Name Last Name
player1 --------------- player1 ----------------------- player1
player2 ---------------- player2 ------------------------- player2
player3 ------------------ player3 ---------------------- player3
However, my results are displayed like this:
First Name Last Name
player1 - player2 - player3
First Name Last Name
player1 - player2 - player3
etc.
firstname, lastname, player1, player2 and player 3 are all columns in my db table. Each time a new user appears, they are inserted into a new line with new players.
the code:
<h1>Draft Order</h1>
<?php
$con = mysqli_connect("localhost", "", "", "");
$stmt = mysqli_query($con,"SELECT * FROM user_players");
while($row = mysqli_fetch_array($stmt)) {
$player1 = $row['player1'];
$player2 = $row['player2'];
$player3 = $row['player3'];
?>
<div class="inline">
<?php echo $row['firstname'] . " " . $row['lastname']; ?>
</div>
<div class="draftBorder">
<?php
echo $player1;
echo $player2;
echo $player3;
?>
</div>
<?php
}
?>
CSS
.inline {
display: inline;
padding: 10px;
}
.draftBorder {
border: 1px solid black;
display: block;
}
firstname lastname 'inline', , .
"draftBorder" , .
, .
UPDATE: ...
firstname - lastname
player1
player2
player3
player1
player2
player3
player1
player2
player3
: float: left;
------ player1
player3 ------------------ player2
------ player1
player3 ------------------ player2
------ player1
player3 ------------------ player2