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 <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > 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 <[EMAIL PROTECTED]> > > Date: Wed, 2 Jan 2002 09:05:42 -0600 > > To: [EMAIL PROTECTED] > > 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:[EMAIL PROTECTED]] > > Sent: Wednesday, January 02, 2002 8:56 AM > > To: [EMAIL PROTECTED] > > 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: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- > > PHP Database 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 Database 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]