actually, taht did work nicely, but I'm not sure how I can use that code to display listings for the current month.
I did find some code that pretty much doews what I'm looking for, but I have no clue how or if it's very well written. I've spent the better part of the day looking up bits using the manual, but I think it's getting me even more confused. Anyone know where I can find a tutorial or snippet of code with similar functionality that I can disect and hopefully learn from?
Here's what I found. Any pro'sout there interested in breaking it down or explaining any of it... I'm all ears (eyes).
<?php
include ("include/header.inc.php");
include("include/dbconnect.php");
function fixlen($fixit) {
if (strlen($fixit)<2) {
return "0$fixit";
} else {
return $fixit;
}
}
function gen_month($year,$month) {
global $pgm;
$mon_date = getdate(mktime(0,0,0,$month,1,$year));
$mon_name = $mon_date['month'];
$mon_total_days = strftime( "%d",mktime(0,0,0,$month+1,0,$year));
$prev_date = getdate(mktime(0,0,0,$month-1,1,$year));
$prev = $prev_date['year'] . fixlen($prev_date['mon']);
$next_date = getdate(mktime(0,0,0,$month+1,1,$year));
$next = $next_date['year'] . fixlen($next_date['mon']);
echo "<a href=$pgm?yyyymm=$prev><<</a>";
echo " <b>$mon_name $year</b>";
echo " <a href=$pgm?yyyymm=$next>>></a><br><br>";
}
function show_events($year,$month) {
global $db_table_name,$db_column_name,$db;
global $pgm;
$date1 = date("Y-m-d", mktime(0,0,0,$month,1,$year));
$date2 = date("Y-m-d", mktime(0,0,0,$month+1,1,$year));
$qrsql = "SELECT * FROM $db_table_name WHERE ($db_column_name>='$date1' " .
"and $db_column_name<'$date2') ORDER BY $db_column_name";
$qr_ret = mysql_query($qrsql, $db);
$qr_num=mysql_num_rows($qr_ret);
$lastday = 0;
while($row=mysql_fetch_array($qr_ret)) { $event_date = $row[$db_column_name];
$event_year = substr($event_date,0,4);
$event_month = substr($event_date,5,2);
$event_day = substr($event_date,8,2);
$event_getdate = getdate(mktime(0,0,0,$event_month,$event_day,$event_year));
$day_of_week = $event_getdate['weekday'];
if ($lastday != $event_day) {
if ($lastday <> 0) {
echo "<br>";
}
echo "<b>" . $event_getdate['month'] . " " . $event_getdate['mday'] . " " . $event_getdate['year'] . "</b>";
}
$lastday = $event_day;
echo "<br>" . $row['description'] . "<br>";
}
if ($lastday <> 0) {
echo "<br>";
}
}
?>
<?php
if (isset($yyyymm)) {
if(strlen($yyyymm) == 6) {
$yyyy = substr($yyyymm, 0, 4);
$mm = substr($yyyymm, 4, 2);
}
} else {
$today = getdate();
$yyyy = $today['year'];
$mm = $today['mon'];
}
gen_month($yyyy, $mm);
show_events($yyyy, $mm);
?>