I have pulled user data from a SQL table, but I want to position the data vertically as I would with ex. table-cell. Since I did this in PHP, I cannot figure out how I could do this. Also, I couldn't figure out a way to add CSS to it, so I added some in-line CSS to the whole 'echo'. Here is my code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "shopping_list_users";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT id, username, name, surname FROM users";
$result = $conn->query($sql);
if ($result !== false && $result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
echo "<p style='font-size: 2em; text-shadow: 0px 5px 12px #333333; text-align: left; font-size: 40px; margin: 30px; margin-top: 35px; font-weight: bold'>" .
"ID: " . $row["id"]. "<br>",
"Username: " . $row["username"]. "<br>",
"Name: " . $row["name"]. "<br>",
"Surname: " . $row["surname"]. "<br>";
}
} else {
echo "0 results";
}
$conn->close();
?>
As I said, I want to align the $row data vertically, next to their respective "titles" (ID, Username, Name, Surname).