finding news stories in a selection of months
| From: | Michael Hill | Date: | Mon, 02 Feb 2004 15:10:16 +0000 |
| Subject: | finding news stories in a selection of months | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-176573@lists.php.net to get a copy of this message | ||
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
belongs to, along with the number of news stories each month has. I'm a
bit stuck as i'm really new to this stuff,
thanks for any help, you guys can give,
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['date'];
$firstmonth = substr($firstdate, 4, 6);
$firstyear = substr($firstdate, 0, 4);
$strSQL = "SELECT date from ".$tbl_prefix."news where live=1 order by
date desc limit 0,1";
$result = mysql_query($strSQL,$dbconn);
$lastresult = mysql_fetch_array($result);
$lastdate = $lastresult['date'];
$lastmonth = substr($lastdate, 4, 6);
$lastyear = substr($lastdate, 0, 4);
Michael Hill
Senior Developer
Holler
02076891942
www.holler.co.uk
This message is confidential, you may use and apply the information only
for the intended purpose. Internet communications are not secure and
therefore Holler does not accept legal responsibility for the
contents of this message. Any views or opinions expressed are solely
those of the author and may not represent those of Holler.
If you are not the intended recipient, any disclosure, copying,
distribution
or use of it, or any part of it, in any form whatsoever, and any actions
taken or omitted to be taken in reliance on it, is prohibited and may
be unlawful.