Raj Samani Raj Samani - 2 years ago 110
MySQL Question

How to desc order date field in while loop

How to

DESC
order
Date
field in while loop
How to
DESC
order
Date
field by using while loop select data
First We need ASC ORDER & After We need Display DESC ORDER Date

$start_date="SELECT user_registered FROM wp_users ORDER BY user_registered ASC LIMIT 1";

$date_result=$wpdb->get_results($start_date) or die(mysqli_error());

$date = date('Y-m-d',strtotime($date_result[0]->user_registered));

$end_date = date('Y-m-d');

while ($end_date >= $date)
{
echo $date;

$date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
}


we need desc order
echo $date

Answer Source
while ($end_date >= $date) {
$newData[$i]=$date;
$i++;
$date = date("Y-m-d", strtotime("+1 day", strtotime($date)));
}
$date = date('Y-m-d',strtotime($date_result[0]->user_registered));
$count=count($newData);

for($i=$count;$i>=1;$i--)
{
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download