<?php
$orders = "SELECT orderno,DATE_FORMAT(dateadded, '%d-%m-%Y') AS dateadded,status FROM orders WHERE username='$_SESSION[valid_user]' AND status!='Quote' ORDER BY dateadded DESC,orderno DESC";
?>
but this orders the date by the day only , how do i get it to order by year then month then day?
hmmm...wierd, it should order by actually date, not only by the day. Is dateadded an MySQL date field? I presume it is because you are using the DATE_FORMAT function.
Does it order them correctly if you take out "orderno DESC"?
Try ...
$orders = "SELECT orderno,DATE_FORMAT(dateadded, '%d-%m-%Y') AS fdateadded,status FROM orders WHERE username='$_SESSION[valid_user]' AND status!='Quote' ORDER BY dateadded DESC,orderno DESC";
and use fdateadded in your display/fetch code. ie instead of doing AS dateadded try doing AS somethingelse ( i used fdateadded), but leave the ORDER BY dateadded as is.