Displaying database results in reverse order of built-in and blocked from what is assigned

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;
}
/*------Draft Page---*/
.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

+4
1

, , , , .

    <?php
    $con = mysqli_connect("localhost", "", "", "");
    $stmt = mysqli_query($con,"SELECT CONCAT_WS(" ", first_name, last_name) AS fullname, player1, player2, player3 FROM user_players");

    while($row = mysqli_fetch_array($stmt)) {

    echo '<h1>Draft Order</h1>';

    echo '<div style="display: block; width: 100%;">';
    for($i=1; $i<4; ++$i){


       echo '<div class="draftBorder">';
       echo $row['fullname'];
       echo '</div>';

       echo '<div class="draftBorder">';
       echo $row['fullname'];
       echo '</div>';

       echo '<div class="draftBorder">';
       echo $row['fullname'];
       echo '</div>';


    }

 echo '</div>';



    echo '<div style="display: block; width: 100%;">';
    for($i=1; $i<4; ++$i){
    $player = $row['player'.$i]

       echo '<div class="draftBorder">';
       echo $player;
       echo '</div>';

       echo '<div class="draftBorder">';
       echo $player;
       echo '</div>';

       echo '<div class="draftBorder">';
       echo $player;
       echo '</div>';


    }

 echo '</div>';

 }
?>

draftBorder

.draftBorder {
    border: 1px solid black;
    display: inline-block;
    width: 33.33%;
}
0

Source: https://habr.com/ru/post/1598474/


All Articles