Hi! Could we please enable some services and cookies to improve your experience and our website?
Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code
CREATE TABLE `table` (
id int,
r1 int,
r2 int,
r3 int,
r4 int
);
INSERT INTO `table` VALUES (1, 10, 2, 5, 5), (2, 4, 4, 1, 9);
SELECT id, r1, r2, r3, r4 FROM `table` order by id DESC;
<?php
$conn = &$mysqli;
$sql = "SELECT r1, r2, r3, r4 FROM `table` order by id DESC ";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_array(MYSQLI_NUM))
{
sort($row);
echo '<td>';
echo implode('</td><td>', $row);
echo '</td>' . PHP_EOL;
}
}