Re: [PHP] How to inverse the date sorting [IT WORKS! - THANKS!]
Just as simple as that?! Thank you guys: Fang; Andrew and Joe. Much appreciated. Hope to be able to give a hand myself someday to newbies like me ;-) Won't have to ask this question again. Promessed! Mes salutations, Yves At 12:26 -0500 15/02/2001, Fang Li wrote: >add DESC after order by 'date', it will be > >$sql = "select * from table_name WHERE TO_DAYS(NOW()) - TO_DAYS(date) ><= 21 order by 'date' DESC"; > >Fang > >-Original Message- >From: Malouin Design Graphique [mailto:[EMAIL PROTECTED]] >Sent: February 15, 2001 12:15 PM >To: [EMAIL PROTECTED] >Subject: [PHP] How to inverse the date sorting > > >Hello, > >Anybody here would know, how I could inverse the date sorting or ordering? > >This script below gives me for example: >2001-01-01 >2001-01-15 >2001-01-31 >and so on... > >when I wish it would gives me: >2001-01-31 >2001-01-15 >2001-01-01 >and so on... > >- >$db = mysql_connect("servername.com", "root", "password"); >mysql_select_db("stats", $db); >$sql = "select * from table_name WHERE TO_DAYS(NOW()) - TO_DAYS(date) ><= 21 order by 'date'"; >$result = mysql_query( $sql ); >while ( $row = mysql_fetch_array( $result ) ) > { > echo "$row[date]src=\"$row[indice_url]\">$row[indice]size=\"1\">\n"; > } >?> >- > > >Thanks again for your help. >Merci beaucoup, > >Yves -- Malouin Design Graphique http://www.malouin.qc.ca Québec (Québec) CANADA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] How to inverse the date sorting
add a DESC to your order by clause... fairly simple SQL syntax, could be picked up from a myriad of SQL references and manuals $sql = "select * from table_name WHERE TO_DAYS(NOW()) - TO_DAYS(date) <= 21 order by date DESC"; At 12:14 PM 2/15/01 -0500, Malouin Design Graphique wrote: >Hello, > >Anybody here would know, how I could inverse the date sorting or ordering? > >This script below gives me for example: >2001-01-01 >2001-01-15 >2001-01-31 >and so on... > >when I wish it would gives me: >2001-01-31 >2001-01-15 >2001-01-01 >and so on... > >- >$db = mysql_connect("servername.com", "root", "password"); >mysql_select_db("stats", $db); >$sql = "select * from table_name WHERE TO_DAYS(NOW()) - TO_DAYS(date) <= >21 order by 'date'"; >$result = mysql_query( $sql ); >while ( $row = mysql_fetch_array( $result ) ) > { > echo "$row[date] src=\"$row[indice_url]\">$row[indice] size=\"1\">\n"; > } >?> >- > > >Thanks again for your help. >Merci beaucoup, > >Yves >-- > > > >Malouin Design Graphique >http://www.malouin.qc.ca > >Québec (Québec) CANADA > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] >To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] How to inverse the date sorting
Hello, Anybody here would know, how I could inverse the date sorting or ordering? This script below gives me for example: 2001-01-01 2001-01-15 2001-01-31 and so on... when I wish it would gives me: 2001-01-31 2001-01-15 2001-01-01 and so on... - $row[date]$row[indice]\n"; } ?> - Thanks again for your help. Merci beaucoup, Yves -- Malouin Design Graphique http://www.malouin.qc.ca Québec (Québec) CANADA -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]