SELECT * FROM members ORDER BY date_of_birth DESC;
----------------
php sql Code (PHP)
<?php
$con= mysqli_connect("localhost","tttt","1122","tttt") or die("Error: " . mysqli_error($con));
mysqli_query($con, "SET NAMES 'utf8' ");
$query = "SELECT SUM(NUM) AS NUM, DATE_FORMAT(DATE, '%d-%m-20%y') AS DATE FROM daily GROUP BY DATE_FORMAT (DATE, '%d%-%m%-20%y%')";
$result = mysqli_query( $con, $query);
$resultchart = mysqli_query( $con, $query);
//for chart
$DATE = array();
$NUM = array();
list($b,$a) = array($a,$b);
while($rs = mysqli_fetch_array($resultchart)){
$DATE[] = "\"".$rs['DATE']."\"";
$NUM[] = "\"".$rs['NUM']."\"";
}
$DATE = implode(",", $DATE);
$NUM = implode(",", $NUM);
?>
$query = "SELECT SUM(NUM) AS NUM, DATE_FORMAT(DATE, '%d-%m-20%y') AS DATE FROM daily GROUP BY DATE_FORMAT (DATE, '%d%-%m%-20%y%')";
แก้ไข ช่วยหน่อย
$query = "SELECT SUM(NUM) AS NUM, DATE_FORMAT(DATE, '%d-%m-20%y') AS DATE FROM daily GROUP BY DATE_FORMAT (DATE, '%d%-%m%-20%y%') ORDER BY NUM DATE DESC ";
ขอบคุร ตอบมาด้วยระ
จาก https://www.guru99.com/order-by-desc-and-asc.html