Re: [PHP] finding news stories in a selection of months

2004-02-04 Thread Don Read
On 02-Feb-2004 Michael Hill wrote: > Hi everyone, > heres the code i have: > > $strSQL = "SELECT date from ".$tbl_prefix."news where live=1 order > by > date asc limit 0,1"; > $result = mysql_query($strSQL,$dbconn); > $firstresult = mysql_fetch_array($result); > $firstdate = $firstresult[

Re: [PHP] finding news stories in a selection of months

2004-02-02 Thread Miles Thompson
Michael, Let the database do the work. Check your MySQL docs (assuming you are using MySQL, otherwise check what you have ) for the month() function. Use this in your SELECT, aliasing it so that you do not use the term "month", say pub_month. Your SQL would then look like this $strSQL =

[PHP] finding news stories in a selection of months

2004-02-02 Thread Michael Hill
Hi everyone, I have made written some code (really bad code,I'm sure), that finds the earliest month that has a news story, and the latest month that has a news story. the code is below. I now need to loop through somehow, to build an array, that gives me the month (JAN,FEB,MAR) and the year it bel