Re: Date problem with new year

From: Date: Thu, 03 Jan 2002 01:11:32 +0000
Subject: Re: Date problem with new year
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-15321@lists.php.net to get a copy of this message
This all seems like a waste of cpu cyles to me. Why don't you just write a query like this and be done with it: SELECT * FROM Table WHERE Date_Column = MAX(Date_Column) Fred Faye Keesic <fkeesic@fortfrances.com> wrote in message news:B85882EA.4E27%fkeesic@fortfrances.com... > I had no problems with retrieving news stories from previous days before > 2002, and haven't changed any of my code. This site has been up for a year, > and I can't recall anything like this happening when 2001 rolled around. > > Please excuse the messy code, as this was the first php/db web site I > designed. I took out the formatting stuff... :) > > From my php page, I call a function: > > get_most_recent_stories(date("Ymd")); > - which passes today's date, formatted for for the db > > In my code: > > - this is the function I call - which in turn calls the function below > (no_yesterdays_stories($datetoget) to subtract a day if there is no news > items for the current date, which then calls the same > get_most_recent_stories() function, but passes a "lower" date. Ideally, > these will loop until there are stories found for a certain day. > > > function get_most_recent_stories($datetoget) > > { > //Get the headlines, summaries and links to the story > db_connect(); > $sql = "SELECT * FROM tblStory WHERE (StoryDate=$datetoget)"; > $results = mysql_query($sql); > if ($results) { > if ($row = mysql_fetch_array($results)) { > echo $row[StorySum];} > while ($row = mysql_fetch_array($results)); > } > else { > no_yesterdays_stories($datetoget); } } > } > > function no_yesterdays_stories($datetoget) > > { > //query has returned no stories from yesterday (holiday, etc.) > //keep subtracting on day from yesterday's date until there are stories > found > $datetoget=($datetoget-1); > get_most_recent_stories($datetoget); > } > > -- > Faye Keesic > Computer Programmer Analyst/Web Page Design > > > > From: Rick Emery <remery@excel.com> > > Date: Wed, 2 Jan 2002 09:05:42 -0600 > > To: php-db@lists.php.net > > Subject: RE: [PHP-DB] Date problem with new year > > > > No bug, mate. > > > > Post your code so that we can help ya... > > > > -----Original Message----- > > From: Faye Keesic [mailto:fkeesic@fortfrances.com] > > Sent: Wednesday, January 02, 2002 8:56 AM > > To: php-db@lists.php.net > > Subject: [PHP-DB] Date problem with new year > > > > > > I have a db site that always displays the most recent occurrence of news > > stories.... > > > > The last occurrence of stories was last year (2001-12-31) and up to the new > > year rolling over, I had no difficulty subtracting days, etc. > > > > Is there a bug in Mysql? PHP that I don't know of.. > > > > Please help. > > > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#15321) next »