「PHP」Order ByでMySQLデータを昇順にソートする

サンプルコード

<?php
$con=mysqli_connect("localhost","username","password","database");
if (mysqli_connect_errno())
{
    echo "データベースに接続失敗 " . mysqli_connect_error();
}

$result = mysqli_query($con,"SELECT * FROM Persons ORDER BY age");

while($row = mysqli_fetch_array($result))
{
    echo $row['FirstName'];
    echo " " . $row['LastName'];
    echo " " . $row['Age'];
    echo "<br>";
}

mysqli_close($con);
?>

結果:
yamada taro 33
oosaki mura 35

PHP

Posted by arkgame