Re: SELECT * FROM

From: Date: Wed, 29 Aug 2001 15:04:19 +0000
Subject: Re: SELECT * FROM
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-65031@lists.php.net to get a copy of this message
In your query add ORDER BY "field name like date or ID" DESC. That way it will put them in descending order and I do believe that is what you're looking for :) Jeff ----- Original Message ----- From: "Tarrant Costelloe" <tcostelloe@insur-e.net> To: <php-general@lists.php.net> Sent: Wednesday, August 29, 2001 10:55 AM Subject: [PHP] SELECT * FROM > Hello all, > I have a designing a website of which people can submit news to, this works > fine. Just on the main page I have the following code (snippet); > > <?php > $db = mysql_connect("localhost", "root"); > mysql_select_db("tolkiengossip",$db); > $result = mysql_query("SELECT * FROM news",$db); > if ($myrow = mysql_fetch_array($result)) { > echo "<table width=100% border=1 color=black cellpadding=3 cellspacing=0 > bordercolor=#666666>\n"; > > do { > printf("<tr bgcolor=#CCCC99><b>Title:</b> %s <b>By:</b> > %s | > <b>Date:</b> %s </tr><tr><b> Article:</b> > %s</tr><tr><b> URL:</b> <a href=%s > target=_blank>Click here</a></tr><br>\n", $myrow["title"], > > $myrow["nickname"],$myrow["created"],$myrow["article"],$myrow["link"]); > > } while ($myrow = mysql_fetch_array($result)); > > echo "</font></table>\n"; > > This again works fine just, the problem is that it always leaves the first > ever article submitted at the top of the page and the latest go down and > down etc... I would like to get the latest article to go at the top and > oldest to the bottom. > > Any help would be gratefully apreciated! > > Kind Regards > > Tarrant Costelloe (Taz) > Development Department > ------------------- > (+44) 01273 852014 > (+44) 07714087114 > ------------------ > Qoute/Saying/Poem of the day: > "Common sense is the collection of prejudices acquired by age eighteen." - > George Burns > DISCLAIMER: Any opinions expressed in this email are those of the individual > and not necessarily those of insurE-Com Ltd. (http://www.insur-e.net). This > email and any files transmitted with it, including replies and forwarded > copies (which may contain alterations) subsequently transmitted from > insurE-com, are confidential and solely for the use of the intended > recipient. It may contain material protected by attorney-client privilege. > If you are not the intended recipient or the person responsible for > delivering to the intended recipient, be advised that you have received this > email in error and that any use is strictly prohibited. If you have received > this email in error please notify the technical Infrastructure Group by > telephone on +44 (0)1273 204203 or via mail to tgeorge@insur-e.net, > including a copy of this message. Please then delete this email and destroy > any copies of it. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.general (#65031) next »