Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Output problems with script

Status
Not open for further replies.

jgd12345

Technical User
Joined
Apr 22, 2003
Messages
124
Location
GB
Hi, I was wondering if someone could help with the following. I have been trying to construct an archives list using an example I found on another website. I can't seem to get it to work however and I don't understand what the $month[...] since the variable $month is never assigned. If anyone could help, I'd be greatful. Thanx in advance.

Lee

$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));

function zeroise($number,$threshold) { // function to add leading zeros when necessary
$l=strlen($number);
if ($l<$threshold)
for ($i=0; $i<($threshold-$l); $i=$i+1) { $number='0'.$number; }
return($number);
}

if ($archive_mode == 'monthly') {
$arc_sql=&quot;SELECT DISTINCT YEAR(post_date), MONTH(post_date) FROM $tableposts WHERE post_date < '$now' AND post_category > 0 ORDER BY post_date DESC&quot;;
$arc_result=mysql_query($arc_sql) or die($arc_sql.'<br />'.mysql_error());
while($arc_row = mysql_fetch_array($arc_result)) {
$arc_year = $arc_row['YEAR(post_date)'];
$arc_month = $arc_row['MONTH(post_date)'];
echo $month[zeroise($arc_month,2)].' '.$arc_year;
}
}
 
I don't know myself but I was wondering if you knew how I could get it so it simply displays the example at the bottom, like in a standard archives list. I'm not sure how far mine is off the mark but I would appreciate any help. Thanx

Year
Month
Month
Month

Year
Month
 
k I have loads of posts in my database with a field time (when they were posted dertermined by time()). I need to select the first year and last year a message was posted and do some sort of loop for each of those years. Then I wish for it todo another loop for the first month until the last month a message was posted for the specific year in the previous loop. I would then like it tobe outputted in the format:

First Year
-First month for that year
.
.
-Last month for that year

.
.

Last Year
-First month for that Year
.
.
-Last month for that year

Thanx
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top